From 2914f8007fe94e118cb34f0b715cd286d14b93bc Mon Sep 17 00:00:00 2001 From: feelancer21 <2828397+feelancer21@users.noreply.github.com> Date: Sun, 6 Aug 2023 21:45:36 +0200 Subject: [PATCH] scripts: Direct 'lnd --help' output to a file We are directing the output of 'lnd --help' to a file, as there is currently an issue when an option is mentioned in the help text. --- scripts/check-sample-lnd-conf.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/check-sample-lnd-conf.sh b/scripts/check-sample-lnd-conf.sh index 4b240c13d..311a0aa94 100755 --- a/scripts/check-sample-lnd-conf.sh +++ b/scripts/check-sample-lnd-conf.sh @@ -14,33 +14,37 @@ CONF_FILE=${2:-sample-lnd.conf} # We are reading the default values of lnd from lnd --help. To avoid formatting # issues the width of the terminal is set to 240. This needs a workaround for # CI where we don't have an interactive terminal. +FILE_TMP=$(mktemp) if [ -t 0 ]; then + size=($(stty size)) stty cols 240 - LND_HELP="$(go run -tags="$TAGS" \ - github.com/lightningnetwork/lnd/cmd/lnd --help)"" --end" + go run -tags="$TAGS" github.com/lightningnetwork/lnd/cmd/lnd --help > \ + $FILE_TMP + stty cols ${size[1]} else tmux new-session -d -s simulated-terminal -x 240 -y 9999 tmux send-keys -t simulated-terminal.0 "go run -tags=\"$TAGS\" \ - github.com/lightningnetwork/lnd/cmd/lnd --help; tmux wait -S run" ENTER + github.com/lightningnetwork/lnd/cmd/lnd --help >"$FILE_TMP"; \ + tmux wait -S run" ENTER tmux wait-for run - LND_HELP="$(tmux capture-pane -t simulated-terminal.0 -p)"" --end" tmux kill-session -t simulated-terminal fi +LND_HELP="$(cat $FILE_TMP) --end" + # LND_OPTIONS is a list of all options of lnd including the equal sign, which # is needed to distinguish between booleans and other variables. # It is created by reading the first two columns of lnd --help. -LND_OPTIONS="$(go run -tags="$TAGS" \ - github.com/lightningnetwork/lnd/cmd/lnd --help | \ +LND_OPTIONS="$(cat $FILE_TMP | \ awk '{ option=""; if ($1 ~ /^--/){option=$1}; if ($2 ~ /^--/){option=$2}; - if (match(option, /--[^=]+[=]*/) && - substr(option, length(option)) != "-") + if (match(option, /--[^=]+[=]*/)) {printf "%s ", substr(option, RSTART, RLENGTH)} } END { printf "%s", "--end"}')" +rm $FILE_TMP # OPTIONS_NO_CONF is a list of all options without any expected entries in # sample-lnd.conf. There's no validation needed for these options.