Fix a bug with -e' that broke sometime around when I added -F'. Also,

revamp the `-e' output to truly be sh(1) compatible syntax (even if
passed in `-v' for verbose output).
This commit is contained in:
Devin Teske 2013-11-07 23:04:40 +00:00
parent 671d0e72a7
commit 379cb6ba59
2 changed files with 25 additions and 13 deletions

View File

@ -300,13 +300,14 @@ fi
# Process `-e', `-n', and `-N' command-line options
#
SEP=': '
[ "$SHOW_EQUALS" ] && SEP='="'
[ "$SHOW_FILE" ] && SHOW_EQUALS=
[ "$SHOW_NAME" ] || SHOW_EQUALS=
[ "$SYSRC_VERBOSE" = "0" ] && SYSRC_VERBOSE=
if [ ! "$SHOW_VALUE" ]; then
SHOW_NAME=1
SHOW_EQUALS=
fi
[ "$SHOW_EQUALS" ] && SEP='="'
#
# Process `-j jail' and `-R dir' command-line options
@ -545,7 +546,11 @@ while [ $# -gt 0 ]; do
file=$( f_sysrc_find "$NAME" )
[ "$file" = "$RC_DEFAULTS" -o ! "$file" ] && \
file=$( f_sysrc_get 'rc_conf_files%%[$IFS]*' )
echo -n "$file: "
if [ "$SHOW_EQUALS" ]; then
echo -n ": $file; "
else
echo -n "$file: "
fi
fi
#
@ -587,14 +592,13 @@ while [ $# -gt 0 ]; do
if f_sysrc_set "$NAME" "${1#*=}"; then
if [ "$SHOW_FILE" ]; then
after=$( f_sysrc_find "$NAME" )
echo -n "${SHOW_NAME:+$NAME$SEP}"
echo -n "$before${SHOW_EQUALS:+\"}"
echo " -> $after"
else
after=$( f_sysrc_get "$NAME" )
echo -n "${SHOW_NAME:+$NAME$SEP}"
echo "$before -> $after"
fi
echo -n "${SHOW_NAME:+$NAME$SEP}"
echo -n "$before${SHOW_EQUALS:+\" #}"
echo -n " -> ${SHOW_EQUALS:+\"}$after"
echo "${SHOW_EQUALS:+\"}"
fi
fi
;;
@ -642,8 +646,13 @@ while [ $# -gt 0 ]; do
continue
fi
[ "$SYSRC_VERBOSE" ] && \
echo -n "$( f_sysrc_find "$NAME" ): "
if [ "$SYSRC_VERBOSE" ]; then
if [ "$SHOW_EQUALS" ]; then
echo -n ": $( f_sysrc_find "$NAME" ); "
else
echo -n "$( f_sysrc_find "$NAME" ): "
fi
fi
#
# If `-N' is passed, simplify the output

View File

@ -70,10 +70,13 @@ Show default value(s) only (this is the same as setting RC_CONFS to NULL or
passing `-f' with a NULL file-argument).
.It Fl e
Print query results as
.Ql var=value
.Pq useful for producing output to be fed back in .
Ignored if
.Fl n
.Xr sh 1
compatible syntax
.Pq for example, Ql var=value .
Ignored if either
.Ql Fl n
or
.Ql Fl F
is specified.
.It Fl f Ar file
Operate on the specified file(s) instead of the files obtained by reading the