Skip to content

Commit 83e6857

Browse files
committed
inline-source: inline also if $srcdir contains spaces
Add new syntax for source inline: # set '$inline_source_dir' to `dirname "$0"/` inline_source_dir=`echo "$0" |${SED-sed} 's|[^/]*$||'` . "$inline_source_dir"/sourced-file This version avoids "`"sth"`" like commands (nested quotes), while we are now able to use inline-source script within directory which pathname contains spaces. As a side effect, we save some fork() calls because the directory is constructed only once. Related to github issue #6. * build-aux/inline-source: Move ourself to the new syntax, document new syntax. (func_include): Parse the new syntax, quote $progpath properly. * build-aux/bootstrap.in: Use new syntax. * bootstrap: Sync with new sources.
1 parent 0d95666 commit 83e6857

File tree

3 files changed

+39
-15
lines changed

3 files changed

+39
-15
lines changed

bootstrap

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
## DO NOT EDIT - This file generated from build-aux/bootstrap.in
3-
## by inline-source v2016-02-21.11
3+
## by inline-source v2016-10-21.11
44

55
# Bootstrap an Autotooled package from checked-out sources.
66
# Written by Gary V. Vaughan, 2010
@@ -222,6 +222,7 @@ vc_ignore=
222222
## External Libraries. ##
223223
## ------------------- ##
224224

225+
225226
# Source required external libraries:
226227
# Set a version string for this script.
227228
scriptversion=2016-02-28.16; # UTC
@@ -2822,7 +2823,7 @@ test extract-trace = "$progname" && func_main "$@"
28222823
# End:
28232824

28242825
# Set a version string for *this* script.
2825-
scriptversion=2016-02-28.16; # UTC
2826+
scriptversion=2016-10-21.11; # UTC
28262827

28272828

28282829
## ------------------- ##

build-aux/bootstrap.in

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,15 @@ vc_ignore=
220220
## External Libraries. ##
221221
## ------------------- ##
222222

223+
inline_source_dir=`echo "$0" |${SED-sed} 's|[^/]*$||'`
224+
223225
# Source required external libraries:
224-
. `echo "$0" |${SED-sed} 's|[^/]*$||'`"funclib.sh"
225-
. `echo "$0" |${SED-sed} 's|[^/]*$||'`"options-parser"
226-
. `echo "$0" |${SED-sed} 's|[^/]*$||'`"extract-trace"
226+
. "$inline_source_dir"funclib.sh
227+
. "$inline_source_dir"options-parser
228+
. "$inline_source_dir"extract-trace
227229

228230
# Set a version string for *this* script.
229-
scriptversion=2016-02-28.16; # UTC
231+
scriptversion=2016-10-21.11; # UTC
230232

231233

232234
## ------------------- ##

build-aux/inline-source

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
# Please report bugs or propose patches to:
1919
# <https://github.com/gnulib-modules/bootstrap/issues>
2020

21+
inline_source_dir=`echo "$0" |${SED-sed} 's|[^/]*$||'`
22+
2123
# Source required external libraries:
22-
. `echo "$0" |${SED-sed} 's|[^/]*$||'`"funclib.sh"
23-
. `echo "$0" |${SED-sed} 's|[^/]*$||'`"options-parser"
24+
. "$inline_source_dir"funclib.sh
25+
. "$inline_source_dir"options-parser
2426

2527
# Set a version string for *this* script.
26-
scriptversion=2016-02-21.11; # UTC
28+
scriptversion=2016-10-21.11; # UTC
2729

2830

2931
## ------ ##
@@ -35,9 +37,14 @@ scriptversion=2016-02-21.11; # UTC
3537

3638
# Recursively scan through a FILE passed on the command line, replacing
3739
# either of the following:
38-
# . "relative/file"
39-
# . `echo "$0" |edit`"relative/file"
40-
# with the contents of the referenced files.
40+
#
41+
# a) . "relative/file"
42+
# b) . `echo "$0" |edit`"relative/file"
43+
# c) . "$inline_source_dir"/relative/file
44+
#
45+
# with the contents of the referenced files. When the c) option is used,
46+
# '$inline_source_dir' must be explicitly set to script's source directory
47+
# within the source file. See the example few lines above.
4148

4249

4350
## ---------------- ##
@@ -118,6 +125,11 @@ func_include ()
118125
_G_scriptdir=`echo "$1" |$SED 's|[^/]*$||'`
119126
test -n "$_G_scriptdir" || _G_scriptdir="./"
120127

128+
func_quote_arg unquoted "$progpath"
129+
prog=$func_quote_arg_unquoted_result
130+
131+
export inline_source_dir=$_G_scriptdir
132+
121133
$AWK '
122134
BEGIN { magic = '${_RECURSE_MAGIC-0}'; }
123135
@@ -129,16 +141,25 @@ func_include ()
129141
next;
130142
}
131143
144+
/^inline_source_dir=.*/ {
145+
next;
146+
}
147+
148+
/^\. "\$inline_source_dir.*/ {
149+
system (sprintf ("env _RECURSE_MAGIC=%d \"'"$prog"'\" %s", magic, $2));
150+
next;
151+
}
152+
132153
/^\. ['\''"].*['\''"]$/ {
133154
file = substr ($2, 2, length ($2) -2);
134-
system (sprintf ("env _RECURSE_MAGIC=%d '$progpath' %s", magic, file));
155+
system (sprintf ("env _RECURSE_MAGIC=%d \"'"$prog"'\" %s", magic, file));
135156
next;
136157
}
137158
138159
/^\. `echo [^`]*`['\''"][^'\''"]*['\''"]$/ {
139160
tail = substr ($0, match ($0, /`['\''"]/));
140-
file = substr (tail, 3, length (tail) -3);
141-
system (sprintf ("env _RECURSE_MAGIC=%d '$progpath' '"$_G_scriptdir"'%s", magic, file));
161+
file = substr (tail, 3, length (tail) -3);
162+
system (sprintf ("env _RECURSE_MAGIC=%d \"'"$prog"'\" '"$_G_scriptdir"'%s", magic, file));
142163
next;
143164
}
144165

0 commit comments

Comments
 (0)