Skip to content

Commit ae47252

Browse files
authored
Merge pull request #105 from matejak/perms
Fixed incorrect permission of generated non-script output files.
2 parents c73f667 + f597b6b commit ae47252

File tree

7 files changed

+40
-14
lines changed

7 files changed

+40
-14
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
2.9.0 (TBA)
22
------------------
33

4+
Buxfixes:
5+
46
* Fixed typo in `argbash-init` and updated obsolete/incaccurate hints (#97).
7+
* Fixed incorrect permission of non-script output files (#104).
58

69

710
2.8.1 (2019-06-30)

bin/argbash

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030

3131
die()
3232
{
33-
local _ret=$2
34-
test -n "$_ret" || _ret=1
35-
test "$_PRINT_HELP" = yes && print_help >&2
33+
local _ret="${2:-1}"
34+
test "${_PRINT_HELP:-no}" = yes && print_help >&2
3635
echo "$1" >&2
37-
exit ${_ret}
36+
exit "${_ret}"
3837
}
3938

4039
# validators
@@ -407,6 +406,18 @@ get_parsing_code()
407406
echo "$_newerfile"
408407
}
409408

409+
410+
# $1: The output file
411+
# $2: The output type string
412+
set_output_permission()
413+
{
414+
if grep -q '\<script\>' <<< "$2"
415+
then
416+
chmod a+x "$1"
417+
fi
418+
}
419+
420+
410421
# MS Windows compatibility fix
411422
discard=/dev/null
412423
test -e $discard || discard=NUL
@@ -466,7 +477,7 @@ fi
466477
if test "$outfname" != '-'
467478
then
468479
printf "%s\\n" "$output" > "$outfname"
469-
chmod a+x "$outfname"
480+
set_output_permission "$outfname" "$_arg_type"
470481
else
471482
printf "%s\\n" "$output"
472483
fi

bin/argbash-1to2

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ version=2.8.1
1818

1919
die()
2020
{
21-
local _ret=$2
22-
test -n "$_ret" || _ret=1
23-
test "$_PRINT_HELP" = yes && print_help >&2
21+
local _ret="${2:-1}"
22+
test "${_PRINT_HELP:-no}" = yes && print_help >&2
2423
echo "$1" >&2
25-
exit ${_ret}
24+
exit "${_ret}"
2625
}
2726

2827

bin/argbash-init

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ version=2.8.1
2626

2727
die()
2828
{
29-
local _ret=$2
30-
test -n "$_ret" || _ret=1
31-
test "$_PRINT_HELP" = yes && print_help >&2
29+
local _ret="${2:-1}"
30+
test "${_PRINT_HELP:-no}" = yes && print_help >&2
3231
echo "$1" >&2
33-
exit ${_ret}
32+
exit "${_ret}"
3433
}
3534

3635
# validators

src/argbash.m4

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,18 @@ get_parsing_code()
190190
echo "$_newerfile"
191191
}
192192

193+
194+
# $1: The output file
195+
# $2: The output type string
196+
set_output_permission()
197+
{
198+
if grep -q '\<script\>' <<< "$2"
199+
then
200+
chmod a+x "$1"
201+
fi
202+
}
203+
204+
193205
# MS Windows compatibility fix
194206
discard=/dev/null
195207
test -e $discard || discard=NUL
@@ -249,7 +261,7 @@ fi
249261
if test "$outfname" != '-'
250262
then
251263
printf "%s\\n" "$output" > "$outfname"
252-
chmod a+x "$outfname"
264+
set_output_permission "$outfname" "$_arg_type"
253265
else
254266
printf "%s\\n" "$output"
255267
fi

tests/regressiontests/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ basic-docopt: $(TESTDIR)/basic.txt
563563
grep -q "\[<pos-opt>\]" $<
564564
grep -q "\[--opt_arg OPT_ARG\]" $<
565565
grep -q "\s-o OPT_ARG, --opt_arg OPT_ARG\s" $<
566+
! test -x $<
566567

567568
test-onlyopt-docopt: $(TESTDIR)/test-onlyopt.txt
568569
grep -q "\[--opt-repeated OPT-REPEATED\]\.\.\." $<

tests/regressiontests/make/tests/tests-docopt.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ADD_DOCOPT_TEST([basic], [[
22
grep -q "\[<pos-opt>\]" $<
33
grep -q "\[--opt_arg OPT_ARG\]" $<
44
grep -q "\s-o OPT_ARG, --opt_arg OPT_ARG\s" $<
5+
! test -x $<
56
]])
67

78
ADD_DOCOPT_TEST([test-onlyopt], [[

0 commit comments

Comments
 (0)