Skip to content

Commit 2e7f2a9

Browse files
committed
Fix #7: Ignore function definitions in set output
Updates the sed script in flux.sh which is used to convert the output of set into a sed script. This script no terminates if it encounters a function definition.
1 parent 4a984fd commit 2e7f2a9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/main/scripts/flux.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,20 @@ if [ -z "$FLUX_JAVA_OPTIONS" ] ; then
6363
fi
6464
# This sed script turns the output of set into a sed script
6565
# which replaces the dollar prefixed name of each environment
66-
# variable with its value:
66+
# variable with its value. As the output of the set command
67+
# is a list of variables followed by a list of functions, the
68+
# script terminates at the first line which appears not to be
69+
# a variable definition:
6770
vars_to_script=$( cat <<'EOF'
68-
s/\\/\\\\/g ;
69-
s/!/\\!/g ;
70-
s/='(.*)'$/=\1/ ;
71-
s/^([^=]+)=(.*)$/s!\\$\1!\2!g ; /g
71+
s/^[^=]*$//g ; # is this not a variable definition?
72+
t quit ; # then jump to quit
73+
s/\\/\\\\/g ; # otherwise escape backslashes,
74+
s/!/\\!/g ; # escape exclamation marks,
75+
s/='(.*)'$/=\1/ ; # remove quotes,
76+
s/^([^=]+)=(.*)$/s!\\$\1!\2!g ; /g ; # convert to sed regexp command
77+
b ; # and continue with next line
78+
: quit
79+
q
7280
EOF
7381
)
7482
substitute_vars_script=$( set | sed -r "$vars_to_script" )

0 commit comments

Comments
 (0)