Skip to content

Commit aefefef

Browse files
authored
Merge pull request #111 from matejak/fix_inplace
Added the in-place option to the .m4 source.
2 parents 82e85c3 + eae1874 commit aefefef

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

bin/argbash

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,9 @@ then
469469
fi
470470

471471
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
472+
if test "$_arg_in_place" = on
473+
then
474+
_arg_output="$infile"
474475
fi
475476
test -n "$_arg_output" || { echo "The output can't be blank - it is not a legal filename!" >&2; exit 1; }
476477
outfname="$_arg_output"
@@ -505,5 +506,4 @@ else
505506
printf "%s\\n" "$output"
506507
fi
507508

508-
# # <-- needed because of Argbash
509-
# ] <-- needed because of Argbash
509+
# # ] <-- needed because of Argbash

bin/argbash-init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ else
416416
do_script_separate "$parsing_library_file" > "$outfname"
417417
fi
418418
fi
419-
chmod a+x -- "$outfname"
419+
chmod a+x "$outfname"
420420
fi
421421

422422
#

src/argbash.m4

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# DEFINE_SCRIPT_DIR
99
# ARG_POSITIONAL_SINGLE([input], [The input template file (pass '-' for stdin)])
1010
# ARG_OPTIONAL_SINGLE([output], o, [Name of the output file (pass '-' for stdout)], -)
11+
# ARG_OPTIONAL_BOOLEAN([in-place], [i], [Update a bash script in-place], [off])
1112
# ARG_OPTIONAL_SINGLE([type], t, [Output type to generate], [bash-script])
1213
# ARG_OPTIONAL_BOOLEAN([library],, [Whether the input file if the pure parsing library])
1314
# ARG_OPTIONAL_SINGLE([strip],, [Determines what to have in the output], [none])
@@ -214,6 +215,11 @@ trap cleanup EXIT
214215
# If we are reading from stdout, then create a temp file
215216
if test "$infile" = '-'
216217
then
218+
if test "$_arg_in_place" = 'on'
219+
then
220+
echo "Cannot use stdin input with --in-place option!" >&2
221+
exit 1;
222+
fi
217223
infile=temp_in_$$
218224
_files_to_clean+=("$infile")
219225
cat > "$infile"
@@ -233,6 +239,10 @@ then
233239
fi
234240

235241
test -f "$infile" || _PRINT_HELP=yes die "argument '$infile' is supposed to be a file!" 1
242+
if test "$_arg_in_place" = on
243+
then
244+
_arg_output="$infile"
245+
fi
236246
test -n "$_arg_output" || { echo "The output can't be blank - it is not a legal filename!" >&2; exit 1; }
237247
outfname="$_arg_output"
238248
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

Comments
 (0)