Commit Graph

15456 Commits

Author SHA1 Message Date
Denys Vlasenko
bae8fc4436 xargs: use bb_ask_y_confirmation_FILE() instead of homegrown copy
function                                             old     new   delta
bb_ask_y_confirmation_FILE                             -      83     +83
inetd_main                                          2033    2043     +10
udhcp_send_kernel_packet                             295     301      +6
rmescapes                                            306     310      +4
send_tree                                            353     355      +2
i2cdetect_main                                       674     672      -2
confirm_or_abort                                      43      38      -5
get_terminal_width_height                            242     234      -8
bb_ask_y_confirmation                                 76      10     -66
xargs_main                                           823     755     -68
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/5 up/down: 105/-149)          Total: -44 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 15:23:10 +02:00
Denys Vlasenko
77cb6b99a4 libbb: rename bb_ask -> bb_ask_noecho, bb_ask_confirmation -> bb_ask_y_confirmation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 15:08:12 +02:00
Denys Vlasenko
2f094ae821 telnet: move winsize detection closer to I/O loop, delete non-functioning debug code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 15:02:20 +02:00
Denys Vlasenko
e0afe0a9fd ftpd: allow -A if !FTPD_AUTHENTICATION as well
Users will be able to use "ftpd -A" in scripts regardless of build config

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 14:18:42 +02:00
Denys Vlasenko
8edaaced16 ftpd: added -A option to disable all authentication, closes 10921
function                                             old     new   delta
packed_usage                                       32745   32777     +32
ftpd_main                                           2162    2156      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 32/-6)              Total: 26 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 14:02:21 +02:00
Denys Vlasenko
32c3e3a44c wget,ftpd: shorten and reuse strings
function                                             old     new   delta
wget_main                                           2382    2386      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 4/0)                 Total: 4 bytes
   text	   data	    bss	    dec	    hex	filename
 934228	    477	   7296	 942001	  e5fb1	busybox_old
 934202	    477	   7296	 941975	  e5f97	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 13:22:52 +02:00
Denys Vlasenko
9fe8bd8d61 httpd: do not default to Content-type: application/octet-stream
Instead, simply don't send this header.

On Mon, Apr 2, 2018 at 8:17 PM, xisd <xisd-dev@riseup.net> wrote:
> I had some trouble using busybox httpd to serve a static website and I
> thought the issue might be of interest.
>
> My problem is related to something that seem quite common for static
> site generator :  the use of html files without the '.html' extension
> (it is called 'clean url'...)
>
> Most web server guess that these files are html and display them like
> any other .html files.
>
> From what I understood, the MIME type for files without extension in
> busybox htttp default settings is 'application/octet-stream', and
> because of that 'clean url' pages are not displayed.
>
> It is only trouble because I wanted to deploy my website on freshly
> installed linux without editing any configuration.
>
> The default MIME setting make sense to me as it is, I just thought that
> might be worth mentioning since the use of 'clean url' seem to be a
> common practice for static sites generators (the one I use is callled
> 'yellow' (https://github.com/datenstrom/yellow))
>
> Here is a link for the related issue on github :
> https://github.com/datenstrom/yellow/issues/317

function                                             old     new   delta
send_headers                                         702     718     +16
send_headers_and_exit                                 23      20      -3
handle_incoming_and_exit                            2794    2791      -3
send_file_and_exit                                   772     756     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 16/-22)             Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 01:13:30 +02:00
Denys Vlasenko
6b6a3d9339 scripts/kconfig/mconf.c: survive is SIGWINCH is not defined
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06 19:05:53 +02:00
Denys Vlasenko
2c99702810 i386: make stack size optimization selectable, and allow i486 insns (bswap)
It's hard to imagine someone still using non-bswap equipped CPU

function                                             old     new   delta
xmalloc_optname_optval                               888     879      -9
write_leases                                         214     205      -9
write32                                               36      27      -9
update_status                                        612     603      -9
udhcpd_main                                         1468    1459      -9
udhcpc_main                                         2708    2699      -9
udhcp_run_script                                     804     795      -9
sha256_process_block64                               423     414      -9
sha1_process_block64                                 337     328      -9
sha1_end                                              80      71      -9
send_ACK                                             161     152      -9
select_lease_time                                     64      55      -9
rpm_getint                                           118     109      -9
readprofile_main                                    1719    1710      -9
read32                                                33      24      -9
rdate_main                                           236     227      -9
machtime                                              39      30      -9
inet_addr_match                                      103      94      -9
get_prefix                                           344     335      -9
f_write32                                             31      22      -9
f_read32                                              31      22      -9
dumpleases_main                                      620     611      -9
KeyExpansion                                         197     188      -9
udhcp_str2optset                                     536     518     -18
read_config                                          222     204     -18
lfp_to_d                                              55      37     -18
ipaddr_modify                                       1226    1208     -18
dnsd_main                                           1278    1260     -18
des_crypt                                           1344    1326     -18
d_to_lfp                                             106      88     -18
bb_bswap_64                                           29      11     -18
INET_setroute                                        827     809     -18
read_leases                                          330     309     -21
zcip_main                                           1256    1229     -27
send_offer                                           476     449     -27
ipcalc_main                                          534     507     -27
handle_incoming_and_exit                            2821    2794     -27
fmt_time_bernstein_25                                131     104     -27
common_traceroute_main                              3804    3768     -36
rpm_gettags                                          451     397     -54
parse_args                                          1412    1358     -54
volume_id_probe_hfs_hfsplus                          627     564     -63
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/42 up/down: 0/-732)          Total: -732 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06 19:01:51 +02:00
Denys Vlasenko
2ab994f707 placate gcc-8.0.1 warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06 18:26:33 +02:00
Denys Vlasenko
f5018dac21 hush: fix "unset PS1/PS2", and put them into initial variable set
"unset PS1/PS2" causes prompts to be empty strings

function                                             old     new   delta
hush_main                                           1031    1089     +58
goto_new_line                                         27      33      +6
fgetc_interactive                                    244     245      +1
unset_local_var                                      155     149      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 65/-6)              Total: 59 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06 17:58:21 +02:00
Denys Vlasenko
d1d6d9c5d8 sort: smaller and more agressive FEATURE_SORT_OPTIMIZE_MEMORY
function                                             old     new   delta
sort_main                                           1098    1037     -61

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06 16:44:50 +02:00
Denys Vlasenko
00bd76728d hush: if we did match "LINENO" or "OPTIND", stop further comparisons
function                                             old     new   delta
handle_changed_special_names                          99     101      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06 14:57:53 +02:00
Denys Vlasenko
cf079ffe1c hush: consolidate handling of setting/unsetting of PSn, LINENO, OPTIND
function                                             old     new   delta
handle_changed_special_names                           -      99     +99
unset_local_var                                      256     155    -101
set_local_var                                        557     437    -120
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 99/-221)          Total: -122 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06 14:50:12 +02:00
Denys Vlasenko
de02625985 hush: update to correctly handle changed var_bash[346].tests
function                                             old     new   delta
expand_one_var                                      1612    1604      -8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-05 17:04:53 +02:00
Denys Vlasenko
f2ed39b930 hush: implement "hush -s"
function                                             old     new   delta
hush_main                                           1015    1031     +16
packed_usage                                       32757   32745     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 16/-12)              Total: 4 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-05 16:46:49 +02:00
Denys Vlasenko
d878ccca9c placate gcc 8.0.1 sprintf overflow warnings in config tools
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-05 15:21:34 +02:00
Denys Vlasenko
21b7f1b6b6 hush: fix a few more corner cases with empty-expanding cmds
See added testcases

function                                             old     new   delta
run_pipe                                            1723    1784     +61

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-05 15:15:53 +02:00
Denys Vlasenko
41d8f10813 hush: fix corner cases with exec in empty expansions
Cases like these:

var=val exec >redir

var=val `` >redir

function                                             old     new   delta
run_pipe                                            1701    1723     +22
redirect_and_varexp_helper                            56      55      -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 22/-1)              Total: 21 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-05 14:41:21 +02:00
Denys Vlasenko
929a41d577 hush: less mind-bending set_vars_and_save_old()
function                                             old     new   delta
run_pipe                                            1651    1701     +50
set_local_var                                        510     557     +47
pseudo_exec_argv                                     544     581     +37
redirect_and_varexp_helper                            64      56      -8
set_vars_and_save_old                                164     149     -15
unset_local_var                                      274     256     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/3 up/down: 134/-41)            Total: 93 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-05 14:09:14 +02:00
Denys Vlasenko
4e1dc539e9 hush: "no logic changes" in last commit was not true, fix it up
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-05 13:10:34 +02:00
Denys Vlasenko
34f6b12330 hush: make run_pipe code simpler to understand, no logic changes
function                                             old     new   delta
run_pipe                                            1641    1651     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-05 11:30:17 +02:00
Denys Vlasenko
d358b0b65d hush: fix a bug where we don't properly handle f() { a=A; b=B; }; a= f
function                                             old     new   delta
unset_local_var                                       20     274    +254
leave_var_nest_level                                   -      98     +98
set_vars_and_save_old                                128     164     +36
enter_var_nest_level                                   -      32     +32
builtin_local                                         46      50      +4
pseudo_exec_argv                                     554     544     -10
redirect_and_varexp_helper                            77      64     -13
run_pipe                                            1890    1641    -249
unset_local_var_len                                  267       -    -267
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/3 up/down: 424/-539)         Total: -115 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-05 00:51:55 +02:00
Denys Vlasenko
332e4115c9 hush: make var nesting code independent of "local" support
Also, add code to abort at ~65000 function recursion depth.
SEGVing is not as nice as exiting with a message (and restoring termios!):

$ f() { echo -n .; f; }; f
....<many dots later>....hush: fatal recursion (depth 65281)

function                                             old     new   delta
run_pipe                                            1826    1890     +64
pseudo_exec_argv                                     544     554     +10
parse_and_run_file                                    71      80      +9
i_getch                                              104     107      +3
done_command                                          99     102      +3
set_local_var                                        508     510      +2
helper_export_local                                  214     215      +1
builtin_local                                         49      46      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/1 up/down: 92/-3)              Total: 89 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-04 22:35:13 +02:00
Denys Vlasenko
61407807ab hush: fix for readonly vars in "ro=A ro=B cmd" case
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-04 21:14:28 +02:00
Denys Vlasenko
759ca8a4cb sort: move misplaced comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-04 17:07:21 +02:00
Denys Vlasenko
c29c2e60d8 sort: FEATURE_SORT_OPTIMIZE_MEMORY
On sorting all kernel/linux/arch/ *.[ch] files,
this reduces memory usage by 6%.

	yes | head -99999999 | sort

goes down from 1900Mb to 380 Mb.

function                                             old     new   delta
sort_main                                            862    1098    +236

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-04 17:03:41 +02:00
Denys Vlasenko
ee1fd1246e ash: unbreak PS1 parsing after "ash: parser: Add syntax stack..." commit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-04 13:59:53 +02:00
Denys Vlasenko
fbf44854a3 hush: support "f() (cmd)" functions
Many other shells support this construct

function                                             old     new   delta
parse_stream                                        2950    3018     +68

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-03 14:56:52 +02:00
Denys Vlasenko
49015a60cb hush: fix mishandling of "true | f() { echo QWE; }"
function                                             old     new   delta
run_pipe                                            1820    1826      +6

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-03 13:02:43 +02:00
Denys Vlasenko
5fa0505f8a hush: fix "set -e; false || x=1; echo OK"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-03 11:21:13 +02:00
Denys Vlasenko
11752d46d1 hush: one-word, no-globbing handling of local/export/readonly args
function                                             old     new   delta
done_word                                            738     790     +52

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-03 08:20:58 +02:00
Denys Vlasenko
f50e14632f ash: parser: Fix parameter expansion inside inner double quotes
Upstream email:

    parser: Fix parameter expansion inside inner double quotes

    The parsing of parameter expansion inside inner double quotes
    breaks because we never look for ENDVAR while innerdq is true.

            echo "${x#"${x+''}"''}

    This patch fixes it by pushing the syntax stack if innerdq is
    true and we enter a new parameter expansion.

    This patch also fixes a corner case where a bad substitution error
    occurs within arithmetic expansion.

    Reported-by: Denys Vlasenko <vda.linux@googlemail.com>
    Fixes: ab1cecb40478 (" parser: Add syntax stack for recursive...")
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

function                                             old     new   delta
readtoken1                                          2880    2898     +18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-02 21:00:59 +02:00
Denys Vlasenko
abf755615e hush: fix a backslash-removal bug in case
function                                             old     new   delta
run_list                                            1270    1053    -217

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-02 17:25:18 +02:00
Denys Vlasenko
9a95df9046 ash: expand: Fix bugs with words connected to the right of $@
Upstream email:

    This is actually composed of two bugs.  First of all our tracking
    of quotemark is wrong so anything after "$@" becomes quoted.  Once
    we fix that then the problem is that the first space character
    after "$@" is not recognised as an IFS.

    This patch fixes both.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-02 14:27:50 +02:00
Denys Vlasenko
355ec353be ash: redir: Fix typo in noclobber code
Upstream commit "redir: Fix typo in noclobber code"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-02 13:34:57 +02:00
Denys Vlasenko
c4c2012284 ash: parser: Fix single-quoted patterns in here-documents
Upstream commit:

    From: Herbert Xu <herbert@gondor.apana.org.au>
    Date: Fri, 9 Mar 2018 23:07:53 +0800
    parser: Fix single-quoted patterns in here-documents

    The script

            x=*
            cat <<- EOF
                    ${x#'*'}
            EOF

    prints * instead of nothing as it should.  The problem is that
    when we're in sqsyntax context in a here-document, we won't add
    CTLESC as we should.  This patch fixes it:

    Reported-by: Harald van Dijk <harald@gigawatt.nl>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-02 13:29:20 +02:00
Denys Vlasenko
8b536eb40d hush: remove stray debugging printout
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-02 13:26:16 +02:00
Denys Vlasenko
216913c290 ash: parser: Add syntax stack for recursive parsing
This closes 10821.

Upstream patch:

    From: Herbert Xu <herbert@gondor.apana.org.au>
    Date: Fri, 9 Mar 2018 00:14:02 +0800
    parser: Add syntax stack for recursive parsing

    Without a stack of syntaxes we cannot correctly these two cases
    together:

            "${a#'$$'}"
            "${a#"${b-'$$'}"}"

    A recursive parser also helps in some other corner cases such
    as nested arithmetic expansion with paratheses.

    This patch adds a syntax stack allocated from the stack using
    alloca.  As a side-effect this allows us to remove the naked
    backslashes for patterns within double-quotes, which means that
    EXP_QPAT also has to go.

    This patch also fixes removes any backslashes that precede right
    braces when they are present within a parameter expansion context,
    and backslashes that precede double quotes within inner double
    quotes inside a parameter expansion in a here-document context.

    The idea of a recursive parser is based on a patch by Harald van
    Dijk.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

var_bash3, var_bash4 and var_bash6 tests are updated
with the output given by bash-4.3.43

With this patch, the following tests now pass for ash:

    dollar_repl_slash_bash2.tests
    squote_in_varexp2.tests
    squote_in_varexp.tests
    var_bash4.tests

function                                             old     new   delta
readtoken1                                          2615    2874    +259
synstack_push                                          -      54     +54
evalvar                                              574     571      -3
rmescapes                                            330     310     -20
subevalvar                                          1279    1258     -21
argstr                                              1146    1107     -39
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/4 up/down: 313/-83)           Total: 230 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-02 13:15:37 +02:00
Denys Vlasenko
e84212f834 hush: update information comment about heredoc discrepancy
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01 20:11:23 +02:00
Denys Vlasenko
899ae5337a libbb: new function bb_die_memory_exhausted
function                                             old     new   delta
bb_die_memory_exhausted                                -      10     +10
xstrdup                                               28      23      -5
xsetenv                                               27      22      -5
xrealloc                                              32      27      -5
xputenv                                               22      17      -5
xmalloc                                               30      25      -5
xfdopen_helper                                        40      35      -5
xasprintf                                             44      39      -5
wget_main                                           2387    2382      -5
open_socket                                           54      49      -5
glob_brace                                           419     414      -5
bb_get_chunk_from_file                               146     141      -5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/11 up/down: 10/-55)           Total: -45 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01 19:59:37 +02:00
Quentin Rameau
e2afae6303 sed: prevent overflow of length from bb_get_chunk_from_file
This fragment did not work right:

                temp = bb_get_chunk_from_file(fp, &len);
                if (temp) {
                        /* len > 0 here, it's ok to do temp[len-1] */
                        char c = temp[len-1];

With "int len" _sign-extending_, temp[len-1] can refer to a wrong location
if len > 0x7fffffff.

Signed-off-by: Quentin Rameau <quinq@fifth.space>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01 19:51:14 +02:00
Quentin Rameau
2da9724b56 libbb: remove unnecessary variable in xmalloc_fgets
Signed-off-by: Quentin Rameau <quinq@fifth.space>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01 19:45:36 +02:00
Denys Vlasenko
bb6f573ad2 hush: add a comment where we differ from bash wrt heredoc EOF mark handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01 18:55:00 +02:00
Denys Vlasenko
41fddb4372 parser: Fix backquote support in here-document EOF mark
Upstream commit:

    Author: Herbert Xu <herbert@gondor.apana.org.au>
    Date:   Thu Mar 15 18:27:30 2018 +0800
    parser: Fix backquote support in here-document EOF mark

    Currently using backquotes in a here-document EOF mark is broken
    because dash tries to do command substitution on it.  This patch
    fixes it by checking whether we're looking for an EOF mark during
    tokenisation.

    Reported-by: Harald van Dijk <harald@gigawatt.nl>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

With added fix for quoted-ness of the EOF mark.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01 16:38:32 +02:00
Denys Vlasenko
1e5111b0f8 ash,hush: handle a few more bkslash-newline cases
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-01 03:04:55 +02:00
Denys Vlasenko
32e183e63e shells: fix var_LINENO1.tests false positive, add it to ash tests too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-31 20:31:13 +02:00
Denys Vlasenko
a94eeb0b42 hush: fix heredoc_bkslash_newline1.tests failure
function                                             old     new   delta
parse_stream                                        2787    2827     +40
builtin_type                                         117     115      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-31 20:16:31 +02:00
Denys Vlasenko
220be537a0 ash: use pgetc_eatbnl() in more places
Part of upstream commit:

    Date:   Thu Mar 8 08:37:11 2018 +0100
    Author: Harald van Dijk <harald@gigawatt.nl>
    parser: use pgetc_eatbnl() in more places

    dash has a pgetc_eatbnl function in parser.c which skips any
    backslash-newline combinations. It's not used everywhere it could be.
    There is also some duplicated backslash-newline handling elsewhere in
    parser.c. Replace most of the calls to pgetc() with calls to
    pgetc_eatbnl() and remove the duplicated backslash-newline handling.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Not adding "readtoken1(pgetc_eatbnl(), DQSYNTAX..." changes, since
readtoken1() handles the "starts with backslash + newline" case itself.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-31 19:40:56 +02:00
Martijn Dekker
ad4e961352 ash: 'nolog' and 'debug' options cause "$-" to wreak havoc
Upstream commit:

    Date:   Tue Mar 6 17:40:37 2018 +0000
    expand: 'nolog' and 'debug' options cause "$-" to wreak havoc

    Op 29-03-17 om 20:02 schreef Martijn Dekker:
    > Bug: if either the 'nolog' or the 'debug' option is set, trying to
    > expand "$-" silently aborts parsing of an entire argument.
    >
    > $ dash -o nolog -c 'set -fuC; echo "|$- are the options|"; set +o nolog; echo "|$- are the options|"'
    > |
    > |uCf are the options|
    > $ dash -o debug -c 'set -fuC; echo "|$- are the options|"; set +o debug; echo "|$- are the options|"'
    > |
    > |uCf are the options|

    This turned out to be easy to fix. The routine producing the "$-"
    expansion failed to skip options for which there is no option letter,
    but only a long-form name. In dash, 'nolog' and 'debug' are currently
    the only two such options. Patch below.

    - Martijn

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

In bbox ash, pipefail is the option which exhibited this.

Signed-off-by: Martijn Dekker <martijn@inlv.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-31 18:30:27 +02:00