Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to correct missing pathname quoting in various tools. #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions bootstrap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
## DO NOT EDIT - This file generated from build-aux/bootstrap.in
## by inline-source v2016-02-21.11
## by inline-source v2016-08-16.15

# Bootstrap an Autotooled package from checked-out sources.
# Written by Gary V. Vaughan, 2010
Expand Down Expand Up @@ -224,7 +224,7 @@ vc_ignore=

# Source required external libraries:
# Set a version string for this script.
scriptversion=2016-02-28.16; # UTC
scriptversion=2016-08-15.14; # UTC

# General shell script boiler plate, and helper functions.
# Written by Gary V. Vaughan, 2004
Expand Down Expand Up @@ -370,7 +370,7 @@ func_path_progs ()
func_executable_p "$_G_path_prog" || continue
case `"$_G_path_prog" --version 2>&1` in
*GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
*) $_G_check_func $_G_path_prog
*) $_G_check_func "$_G_path_prog"
func_path_progs_result=$func_check_prog_result
;;
esac
Expand Down Expand Up @@ -2355,11 +2355,11 @@ func_version ()
# <https://github.com/gnulib-modules/bootstrap/issues>

# Make sure we've evaluated scripts we depend on.
test -z "$progpath" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/funclib.sh
test extract-trace = "$progname" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/options-parser
test -z "$progpath" && . "`echo "$0" |${SED-sed} 's|[^/]*$||'`funclib.sh"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test extract-trace = "$progname" && . "`echo "$0" |${SED-sed} 's|[^/]*$||'`options-parser"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar " ... " issue.


# Set a version string.
scriptversion=2016-02-22.14; # UTC
scriptversion=2016-08-15.19; # UTC


## ------ ##
Expand Down Expand Up @@ -2503,7 +2503,7 @@ func_find_tool ()
IFS=$_G_find_tool_save_IFS
_G_progpath=$_G_dir/$_G_prog
test -r "$_G_progpath" && {
_G_curver=`func_tool_version_number $_G_progpath`
_G_curver=`func_tool_version_number "$_G_progpath"`
case $_G_bestver,$_G_curver in
,)
# first non--version responsive prog sticks!
Expand Down Expand Up @@ -2817,12 +2817,12 @@ test extract-trace = "$progname" && func_main "$@"
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-pattern: "20/scriptversion=%:y-%02m-%02d.%02H; # UTC"
# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
# time-stamp-time-zone: "UTC"
# End:

# Set a version string for *this* script.
scriptversion=2016-02-28.16; # UTC
scriptversion=2016-08-15.19; # UTC


## ------------------- ##
Expand Down
8 changes: 4 additions & 4 deletions build-aux/bootstrap.in
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ vc_ignore=
## ------------------- ##

# Source required external libraries:
. `echo "$0" |${SED-sed} 's|[^/]*$||'`"funclib.sh"
. `echo "$0" |${SED-sed} 's|[^/]*$||'`"options-parser"
. `echo "$0" |${SED-sed} 's|[^/]*$||'`"extract-trace"
. "`echo "$0" |${SED-sed} 's|[^/]*$||'`funclib.sh"
. "`echo "$0" |${SED-sed} 's|[^/]*$||'`options-parser"
. "`echo "$0" |${SED-sed} 's|[^/]*$||'`extract-trace"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly. Workaround would be separate variables?

# Set a version string for *this* script.
scriptversion=2016-02-28.16; # UTC
scriptversion=2016-08-15.19; # UTC


## ------------------- ##
Expand Down
10 changes: 5 additions & 5 deletions build-aux/extract-trace
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
# <https://github.com/gnulib-modules/bootstrap/issues>

# Make sure we've evaluated scripts we depend on.
test -z "$progpath" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/funclib.sh
test extract-trace = "$progname" && . `echo "$0" |${SED-sed} 's|[^/]*$||'`/options-parser
test -z "$progpath" && . "`echo "$0" |${SED-sed} 's|[^/]*$||'`funclib.sh"
test extract-trace = "$progname" && . "`echo "$0" |${SED-sed} 's|[^/]*$||'`options-parser"

# Set a version string.
scriptversion=2016-02-22.14; # UTC
scriptversion=2016-08-15.19; # UTC


## ------ ##
Expand Down Expand Up @@ -167,7 +167,7 @@ func_find_tool ()
IFS=$_G_find_tool_save_IFS
_G_progpath=$_G_dir/$_G_prog
test -r "$_G_progpath" && {
_G_curver=`func_tool_version_number $_G_progpath`
_G_curver=`func_tool_version_number "$_G_progpath"`
case $_G_bestver,$_G_curver in
,)
# first non--version responsive prog sticks!
Expand Down Expand Up @@ -481,6 +481,6 @@ test extract-trace = "$progname" && func_main "$@"
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-pattern: "20/scriptversion=%:y-%02m-%02d.%02H; # UTC"
# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
# time-stamp-time-zone: "UTC"
# End:
4 changes: 2 additions & 2 deletions build-aux/funclib.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set a version string for this script.
scriptversion=2016-02-28.16; # UTC
scriptversion=2016-08-15.14; # UTC

# General shell script boiler plate, and helper functions.
# Written by Gary V. Vaughan, 2004
Expand Down Expand Up @@ -145,7 +145,7 @@ func_path_progs ()
func_executable_p "$_G_path_prog" || continue
case `"$_G_path_prog" --version 2>&1` in
*GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
*) $_G_check_func $_G_path_prog
*) $_G_check_func "$_G_path_prog"
func_path_progs_result=$func_check_prog_result
;;
esac
Expand Down
32 changes: 22 additions & 10 deletions build-aux/inline-source
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
# <https://github.com/gnulib-modules/bootstrap/issues>

# Source required external libraries:
. `echo "$0" |${SED-sed} 's|[^/]*$||'`"funclib.sh"
. `echo "$0" |${SED-sed} 's|[^/]*$||'`"options-parser"
. "`echo "$0" |${SED-sed} 's|[^/]*$||'`funclib.sh"
. "`echo "$0" |${SED-sed} 's|[^/]*$||'`options-parser"

# Set a version string for *this* script.
scriptversion=2016-02-21.11; # UTC
scriptversion=2016-08-16.15; # UTC


## ------ ##
Expand All @@ -34,9 +34,10 @@ scriptversion=2016-02-21.11; # UTC
# from the command line.

# Recursively scan through a FILE passed on the command line, replacing
# either of the following:
# any of the following:
# . "relative/file"
# . `echo "$0" |edit`"relative/file"
# . "`echo "$0" |edit`relative/file"
# with the contents of the referenced files.


Expand Down Expand Up @@ -118,27 +119,38 @@ func_include ()
_G_scriptdir=`echo "$1" |$SED 's|[^/]*$||'`
test -n "$_G_scriptdir" || _G_scriptdir="./"

# quote progpath for use in AWK script
func_quote_arg unquoted "$progpath"
_G_qprogpath=$func_quote_arg_unquoted_result

$AWK '
BEGIN { magic = '${_RECURSE_MAGIC-0}'; }
BEGIN { magic = '"${_RECURSE_MAGIC-0}"'; }

/^#!/ && magic == 0 {
print $0;
print "## DO NOT EDIT - This file generated from '$1'";
print "## by '$progname' v'$scriptversion'";
print "## DO NOT EDIT - This file generated from '"$1"'";
print "## by '"$progname"' v'"$scriptversion"'";
magic++;
next;
}

/^\. "`echo [^`]*`[^"]*"$/ {
tail = substr ($0, match ($0, /[^"]`/) +2);
file = substr (tail, 1, length (tail) -1);
system (sprintf ("env _RECURSE_MAGIC=%d '\'"$_G_qprogpath"\'' '\'"$_G_scriptdir"'%s'\''", magic, file));
next;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, to review this - I need to have a deeper look and I run out of time ATM, so I'll have a look later if Gary isn't quicker.

/^\. ['\''"].*['\''"]$/ {
file = substr ($2, 2, length ($2) -2);
system (sprintf ("env _RECURSE_MAGIC=%d '$progpath' %s", magic, file));
system (sprintf ("env _RECURSE_MAGIC=%d '\'"$_G_qprogpath"\'' %s", magic, file));
next;
}

/^\. `echo [^`]*`['\''"][^'\''"]*['\''"]$/ {
tail = substr ($0, match ($0, /`['\''"]/));
file = substr (tail, 3, length (tail) -3);
system (sprintf ("env _RECURSE_MAGIC=%d '$progpath' '"$_G_scriptdir"'%s", magic, file));
system (sprintf ("env _RECURSE_MAGIC=%d '\'"$_G_qprogpath"\'' '\'"$_G_scriptdir"'%s'\''", magic, file));
next;
}

Expand All @@ -154,6 +166,6 @@ exit 0
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-pattern: "20/scriptversion=%:y-%02m-%02d.%02H; # UTC"
# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
# time-stamp-time-zone: "UTC"
# End:
8 changes: 4 additions & 4 deletions tests/test-option-parser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ all_shells_script=$0

. "$abs_aux_dir"/options-parser || exit 1

helper="$__GL_ALL_SHELLS_SHELL $abs_srcdir/test-option-parser-helper"
helper="$abs_srcdir/test-option-parser-helper"

check_output_inner ()
{
Expand All @@ -32,7 +32,7 @@ check_output_inner ()
func_quote pretty ${1+"$@"}
$ECHO "[[ output check ]] args: $func_quote_result"

output=`$helper ${1+"$@"} 2>/dev/null`
output=`$__GL_ALL_SHELLS_SHELL "$helper" ${1+"$@"} 2>/dev/null`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work!

Maybe it is detail, but could we have rather $helper properly quoted and later eval()ed to not copy the ugly $__GL_ALL_SHELLS_SHELL on multiple places?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 2016-08-17 14:38, Pavel Raiskup wrote:

Thanks for your work!

Maybe it is detail, but could we have rather $helper properly quoted and later eval()ed to not copy the ugly $__GL_ALL_SHELLS_SHELL on multiple places?

Sure, I actually did that initially, but then wondered if it might
affect the quote nesting. I'll go back and test it with eval and append
the patch.

Thanks,

Scott

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pavel,

As I suspected, the eval solution breaks several tests as it swallows
empty parameters passed via ${1+"@"}. Here's the closest I could come
up with:

func_quote_arg eval "$abs_srcdir"
_G_qabs_srcdir=$func_quote_arg_result
helper="$__GL_ALL_SHELLS_SHELL
$_G_qabs_srcdir/test-option-parser-helper"

output=eval $helper ${1+"$@"} 2>/dev/null

Tests similar to <-t ''> broke with this solution... if you see another
method to handle the word splitting in the shell argument, I'd willing
to it (I don't think we want to redefine IFS here...)

Thanks,

Scott

On 2016-08-17 14:38, Pavel Raiskup wrote:

In tests/test-option-parser.sh [1]:

@@ -32,7 +32,7 @@ check_output_inner ()
func_quote pretty ${1+"$@"}
$ECHO "[[ output check ]] args: $func_quote_result"

  • output=$helper ${1+"$@"} 2>/dev/null
  • output=$__GL_ALL_SHELLS_SHELL "$helper" ${1+"$@"} 2>/dev/null

Thanks for your work!

Maybe it is detail, but could we have rather $helper properly quoted and later eval()ed to not copy the ugly $__GL_ALL_SHELLS_SHELL on multiple places?

You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub [2], or mute the thread [3].

Links:

[1]
#7 (comment)
[2]
https://github.com/gnulib-modules/bootstrap/pull/7/files/20a6d66266904c00c29f943b71c4f8424db1b4d5#r75113724
[3]
https://github.com/notifications/unsubscribe-auth/AAnGuNF8tF3x--QsugNT8rGQcLxcp_JJks5qgwCygaJpZM4JlzUb

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, forgot to finish. Other solution is to define a quick shell var,
eg:

hshell=$__GL_ALL_SHELLS_SHELL

output=$hshell "$helper" ${1+"$@"} 2>/dev/null

... which is pretty clean looking :)

Scott

On 2016-08-17 14:38, Pavel Raiskup wrote:

In tests/test-option-parser.sh [1]:

@@ -32,7 +32,7 @@ check_output_inner ()
func_quote pretty ${1+"$@"}
$ECHO "[[ output check ]] args: $func_quote_result"

  • output=$helper ${1+"$@"} 2>/dev/null
  • output=$__GL_ALL_SHELLS_SHELL "$helper" ${1+"$@"} 2>/dev/null

Thanks for your work!

Maybe it is detail, but could we have rather $helper properly quoted and later eval()ed to not copy the ugly $__GL_ALL_SHELLS_SHELL on multiple places?

You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub [2], or mute the thread [3].

Links:

[1]
#7 (comment)
[2]
https://github.com/gnulib-modules/bootstrap/pull/7/files/20a6d66266904c00c29f943b71c4f8424db1b4d5#r75113724
[3]
https://github.com/notifications/unsubscribe-auth/AAnGuNF8tF3x--QsugNT8rGQcLxcp_JJks5qgwCygaJpZM4JlzUb

rc=$?
test "$rc" -eq "$exp_retval" \
|| all_shells_error "unexpected exit status $rc $exp_retval"
Expand Down Expand Up @@ -64,7 +64,7 @@ check_retval ()
exp_retval=$1 ; shift
func_quote pretty ${1+"$@"}
$ECHO "[[ retval check ]] args: $func_quote_result"
$helper ${1+"$@"} >/dev/null 2>/dev/null
$__GL_ALL_SHELLS_SHELL "$helper" ${1+"$@"} >/dev/null 2>/dev/null
rc=$?
test "$rc" -eq "$exp_retval" \
|| all_shells_error "unexpected retval $rc (should be $exp_retval)"
Expand All @@ -79,7 +79,7 @@ grep_output ()
func_quote pretty ${1+"$@"}
$ECHO "[[ grep for '$grep_for' ]] args: $func_quote_result"

output=`$helper ${1+"$@"} 2>/dev/null`
output=`$__GL_ALL_SHELLS_SHELL "$helper" ${1+"$@"} 2>/dev/null`
rc=$?
case $output in
*$grep_for*) : ;;
Expand Down