You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
printf'\t%s\n'"<input>: The input template file (pass '-' for stdin)"
89
91
printf'\t%s\n'"-o, --output: Name of the output file (pass '-' for stdout) (default: '-')"
92
+
printf'\t%s\n'"-i, --in-place, --no-in-place: Update a bash script in-place (off by default)"
90
93
printf'\t%s\n'"-t, --type: Output type to generate. Can be one of: 'bash-script', 'posix-script', 'manpage', 'manpage-defs', 'completion' and 'docopt' (default: 'bash-script')"
91
94
printf'\t%s\n'"--library, --no-library: Whether the input file if the pure parsing library (off by default)"
92
95
printf'\t%s\n'"--strip: Determines what to have in the output. Can be one of: 'none', 'user-content' and 'all' (default: 'none')"
@@ -119,6 +122,18 @@ parse_commandline()
119
122
-o*)
120
123
_arg_output="${_key##-o}"
121
124
;;
125
+
-i|--no-in-place|--in-place)
126
+
_arg_in_place="on"
127
+
test"${1:0:5}" = "--no-"&& _arg_in_place="off"
128
+
;;
129
+
-i*)
130
+
_arg_in_place="on"
131
+
_next="${_key##-i}"
132
+
iftest -n "$_next" -a "$_next"!= "$_key"
133
+
then
134
+
{ begins_with_short_option "$_next"&&shift&&set -- "-i""-${_next}""$@"; } || die "The short option '$_key' can't be decomposed to ${_key:0:2} and -${_key:2}, because ${_key:0:2} doesn't accept value and '-${_key:2:1}' doesn't correspond to a short option."
135
+
fi
136
+
;;
122
137
-t|--type)
123
138
test$# -lt 2 && die "Missing value for the optional argument '$_key'." 1
124
139
_arg_type="$(type "$2""type")"||exit 1
@@ -430,6 +445,11 @@ trap cleanup EXIT
430
445
# If we are reading from stdout, then create a temp file
431
446
iftest"$infile" = '-'
432
447
then
448
+
iftest"$_arg_in_place" = 'on'
449
+
then
450
+
echo"Cannot use stdin input with --in-place option!">&2
451
+
exit 1;
452
+
fi
433
453
infile=temp_in_$$
434
454
_files_to_clean+=("$infile")
435
455
cat >"$infile"
@@ -449,6 +469,9 @@ then
449
469
fi
450
470
451
471
test -f "$infile"|| _PRINT_HELP=yes die "argument '$infile' is supposed to be a file!" 1
472
+
if [ $_arg_in_place= on ];then
473
+
_arg_output=$infile
474
+
fi
452
475
test -n "$_arg_output"|| { echo"The output can't be blank - it is not a legal filename!">&2;exit 1; }
453
476
outfname="$_arg_output"
454
477
autom4te --version >"$discard"2>&1|| { echo"You need the 'autom4te' utility (it comes with 'autoconf'), if you have bash, that one is an easy one to get."2>&1;exit 1; }
0 commit comments