aboutsummaryrefslogtreecommitdiff
path: root/shell (follow)
Commit message (Collapse)AuthorAgeFilesLines
* NOFORK fixesDenys Vlasenko2017-08-041-1/+30
| | | | | | | | | | | | | | | | | | "rm -i FILE" and "yes" can now be interrupted by ^C in hush. This also now works: $ usleep 19999999 ^C $ echo $? 130 function old new delta run_pipe 1668 1711 +43 pseudo_exec_argv 312 321 +9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 52/0) Total: 52 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: protect WIFSTOPPED use with #if JOBSJohannes Schindelin2017-07-181-3/+9
| | | | | | | | | | | | This change fixes the build in setups where there are no headers defining WIFSTOPPED and WSTOPSIG (where JOBS has to be set to 0). This partially reverts 4700fb5be (ash: make dowait() a bit more readable. Logic is unchanged, 2015-10-09). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* main: fix the case where user has "halt" as login shell. Closes 9986Denys Vlasenko2017-07-182-2/+2
| | | | | | | | | | halt::0:0::/:/sbin/halt function old new delta run_applet_and_exit 748 751 +3 run_applet_no_and_exit 467 459 -8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fixes for bugs found by make_single_applets.shDenys Vlasenko2017-07-182-23/+7
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* randomconfig fixesDenys Vlasenko2017-07-031-3/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix $HOME/.profile reading if !ASH_EXPAND_PRMT, take 2Denys Vlasenko2017-07-011-8/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix 'trap - 65'Denys Vlasenko2017-07-011-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix $HOME/.profile reading if !ASH_EXPAND_PRMTDenys Vlasenko2017-06-271-6/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix incorrect path in describe_commandYoufu Zhang2017-05-261-13/+3
| | | | | | | | | | | | | | | | | | | | | | | $ PATH=/extra/path:/usr/sbin:/usr/bin:/sbin:/bin \ > busybox sh -xc 'command -V ls; command -V ls; command -Vp ls; command -vp ls' + command -V ls ls is /bin/ls + command -V ls ls is a tracked alias for /bin/ls + command -Vp ls ls is a tracked alias for (null) + command -vp ls Segmentation fault describe_command should respect `path' argument. Looking up in the hash table may gives incorrect index in entry.u.index and finally causes incorrect output or SIGSEGV. function old new delta describe_command 386 313 -73 Signed-off-by: Youfu Zhang <zhangyoufu@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash,hush: fix SIGCHLD interrupting read builtinDenys Vlasenko2017-05-227-10/+34
| | | | | | | | | | | | function old new delta readcmd 169 217 +48 shell_builtin_read 1087 1097 +10 localcmd 366 364 -2 builtin_read 197 193 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 58/-6) Total: 52 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Spelling fixes in comments, documentation, tests and examplesDenys Vlasenko2017-04-174-14/+14
| | | | | | By klemens <ka7@github.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: implement "exec -a ARGV0 CMD ARGV1..."Denys Vlasenko2017-04-121-7/+15
| | | | | | | | | | | | | function old new delta execcmd 71 112 +41 shellexec 221 224 +3 evalcommand 1158 1161 +3 localcmd 364 366 +2 unaliascmd 163 154 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 49/-9) Total: 40 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: make shellexec capable of using separate argv[0] and filename to execDenys Vlasenko2017-04-121-11/+10
| | | | | | | | | | | function old new delta execcmd 71 78 +7 shellexec 221 224 +3 evalcommand 1158 1161 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 13/0) Total: 13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: GETOPT_RESET macroKaarle Ritvanen2017-04-121-7/+1
| | | | | Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: add INT_OFF/ON around allocationsDenys Vlasenko2017-02-031-2/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: improve / fix glob expansionFelix Fietkau2017-01-311-17/+54
| | | | | | | | | | | | | | | | When using musl libc glob() a very long string can cause glob() to fail, which leads to an out of memory error being raised by ash. This can happen easily if a very long quoted string contains *, even though no glob expansion should ever be performed on it (since it's quoted). Fix this by properly parsing control characters and escaping and only accept unquoted metacharacters. While we're at it, unify this check for libc and built-in glob expansion Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* wget: add a big explanation what TLS code implements and what does notDenys Vlasenko2017-01-301-3/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: add comment about APPLET_ODDNAME formatDenys Vlasenko2017-01-292-3/+5
| | | | | | It confused me more than once Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sh: fix FEATURE_SH_STANDALONE help text: it does not enable NOFORKDenys Vlasenko2017-01-261-17/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: commented-out possible fix for 7694Denys Vlasenko2017-01-111-4/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | bash has a feature: it restores termios after a successful wait for a foreground job which had at least one stopped or sigkilled member. The probable rationale is that SIGSTOP and SIGKILL can preclude task from properly restoring tty state. Should we do this too? A reproducer: ^Z an interactive python: $ python Python 2.7.12 (...) >>> ^Z { python leaves tty in -icanon -echo state. We do survive that... } [1]+ Stopped python { ...however, next program (python no.2) does not survive it well: } $ python Python 2.7.12 (...) >>> Traceback (most recent call last): { above, I typed "qwerty<CR>", but -echo state is still in effect } File "<stdin>", line 1, in <module> NameError: name 'qwerty' is not defined The implementation is modeled on bash code and seems to work. However, I'm not sure we should do this. For one: what if I'd fg the stopped python instead? It'll be confused by "restored" tty state. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: 16-bit ->nprocs field is a pain for many CPUsDenys Vlasenko2017-01-111-3/+4
| | | | | | | | | | | | | | | | | | | | | function old new delta getoptscmd 527 540 +13 getjob 280 286 +6 makejob 278 282 +4 forkchild 602 600 -2 waitcmd 208 205 -3 showjob 382 379 -3 getstatus 83 80 -3 dowait 408 405 -3 freejob 93 89 -4 fg_bgcmd 290 286 -4 forkshell 260 255 -5 killcmd 224 218 -6 jobno 17 11 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/10 up/down: 23/-39) Total: -16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: consolidate the code to set termios unbuffered modeDenys Vlasenko2017-01-111-1/+1
| | | | | | | | | | | | | | | | function old new delta set_termios_to_raw - 116 +116 count_lines 72 74 +2 powertop_main 1458 1430 -28 top_main 943 914 -29 more_main 759 714 -45 fsck_minix_main 2969 2921 -48 conspy_main 1197 1135 -62 rawmode 99 36 -63 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/6 up/down: 118/-275) Total: -157 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: reinstate [[ builtinDenys Vlasenko2017-01-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Mike deleted it: commit 39456a18a104b228de240b265bd943251219849d Author: Mike Frysinger <vapier@gentoo.org> Date: Sat Mar 28 12:21:57 2009 +0000 stop lying about [[ test support probably because it was not properly ifdefed around, and was enabled even when bash compat is off. I just tested it - it works: $ [ *.diff = z.diff ]; echo $? 0 $ [[ *.diff = z.diff ]]; echo $? 1 Of course, not all numerous bash tricks of [[ ]] are implemented... function old new delta bltins2 60 72 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: split bash compatible extensions into separate defines. No code changesKang-Che Sung2017-01-111-29/+44
| | | | | | | | Splitting these options makes it self-documenting about what bash-compatible features we have. Signed-off-by: Kang-Che Sung <explorer09@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: split bash compatible extensions into separate defines. No code changesDenys Vlasenko2017-01-111-74/+101
| | | | | | | | Splitting these options makes it self-documenting about what bash-compatible features we have. Signed-off-by: Kang-Che Sung <explorer09@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: shorten output of "help" builtinDenys Vlasenko2017-01-101-9/+12
| | | | | | | | text data bss dec hex filename 891272 485 6856 898613 db635 busybox_old 891232 485 6856 898573 db60d busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: reorder builtins (cd and pwd ought to be close, etc), no code changesDenys Vlasenko2017-01-101-297/+295
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: revert "make dot command search current directory first"Denys Vlasenko2017-01-101-9/+0
| | | | | | | | | | Reverts this: commit 8ad78e1ec7b2e873953f9f476fb63b5893526c39 Author: Denis Vlasenko <vda.linux@googlemail.com> Date: Sun Feb 15 12:40:30 2009 +0000 ash: make dot command search current directory first, as bash does. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shells: make hush test optional, rename ASH_BUILTIN_foo -> ASH_fooDenys Vlasenko2017-01-102-14/+28
| | | | | | | This makes hash and ash more symmetrical wrt config menu and config options. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Big cleanup in config help and descriptionDenys Vlasenko2017-01-102-102/+51
| | | | | | | | | | | | | Redundant help texts (one which only repeats the description) are deleted. Descriptions and help texts are trimmed. Some config options are moved, even across menus. No config option _names_ are changed. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: make echo builtin optionalDenys Vlasenko2017-01-091-9/+20
| | | | | | | | | | It's a bit overkill (who would want it off?) but ash already has it configurable. Let's be symmetric. Also tweak kbuild logic to use ASH_BUILTIN_ECHO to select echo.o, not ASH. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix a bug in argv restoration after sourcing a fileDenys Vlasenko2017-01-091-2/+4
| | | | | | if sourced file "shift"ed argvs so that $1 is NULL, restore wasn't done. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix a bug in argv restoration after sourcing a fileDenys Vlasenko2017-01-095-2/+36
| | | | | | if sourced file "shift"ed argvs so that $1 is NULL, restore wasn't done. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: global_args_malloced is used only if set builtin is enabledDenys Vlasenko2017-01-091-9/+14
| | | | | | | | | | | | | function old new delta run_pipe 1623 1635 +12 builtin_source 210 222 +12 save_and_replace_G_args 70 60 -10 builtin_shift 132 94 -38 restore_G_args 98 - -98 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/2 up/down: 24/-146) Total: -122 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix 'defined but not used' warningDenys Vlasenko2017-01-091-0/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: remove redundand test for ENABLE_HUSH_JOBDenys Vlasenko2017-01-091-3/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: fix kill builtin without jobs supportDenys Vlasenko2017-01-091-12/+8
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* typo fixDenys Vlasenko2017-01-091-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: conditionalize print_escaped() on EXPORT || TRAPDenys Vlasenko2017-01-081-0/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: make memleak builtin optionalDenys Vlasenko2017-01-081-4/+13
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: make export builtin optionalDenys Vlasenko2017-01-081-11/+26
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: make umask builtin optionalDenys Vlasenko2017-01-081-0/+13
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: make set/unset builtins optionalDenys Vlasenko2017-01-081-5/+35
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: make read and trap builtins optionalDenys Vlasenko2017-01-081-71/+118
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: kill builtin and kill %jobspec supportDenys Vlasenko2017-01-081-4/+130
| | | | | | | | | | | | | Also made it and printf, type and wait builtins optional. function old new delta builtin_kill - 323 +323 bltins1 336 348 +12 builtin_type 114 116 +2 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 337/0) Total: 337 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: support %%, %+ and % jobspec (meaning "current job")Denys Vlasenko2017-01-081-9/+21
| | | | | | | | function old new delta parse_jobspec 83 133 +50 builtin_wait 278 283 +5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: fix open fds leaking in redirects. Closes 9561Denys Vlasenko2017-01-075-4/+39
| | | | | | | | | | | | | | | commit e19923f6652a638ac39c84012e97f52cf5a7568e deleted clearredir() call in shellexec(): ash: [REDIR] Remove redundant CLOEXEC calls Upstream commit: Now that we're marking file descriptors as CLOEXEC in savefd, we no longer need to close them on exec or in setinputfd. but it missed one place where we don't set CLOEXEC. Fixing this. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* ash: explicltly group ash optionsKang-Che Sung2017-01-062-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This would makes all ash options indented inside "ash" in menuconfig. It appears that menuconfig has a limit at tracking multiple dependency lines like this (it looks like a "diamond problem" but I'm not sure if it is): ---ASH <---------- / \ ASH_OPTIMIZE_FOR_SIZE !NOMMU <-*----SH_IS_ASH <----[OR] <--ASH_INTERNAL_GLOB \ / ASH_RANDOM_SUPPORT ---BASH_IS_ASH <-- [...] The kconfig-language document [1] states that: > If a menu entry somehow depends on the previous entry, it can be > made a submenu of it. First, the previous (parent) symbol must be > part of the dependency list and then one of these two conditions > must be true: > - the child entry must become invisible, if the parent is set to 'n' [BusyBox ash used to satisfy this, but no longer does] > - the child entry must only be visible, if the parent is visible [BusyBox ash configs actually satisfy this, but because of "diamond" above this might not be easily detected] So I found out a direct workaround: by making ash options explicitly depend on !NOMMU, we can tell menuconfig that rule 2 above is satisfied without any more tracking. --------------------- / \ !NOMMU <-*-----ASH <-------- \ \ \ \ ASH_OPTIMIZE_FOR_SIZE *---SH_IS_ASH <---[OR]-[AND] <--ASH_INTERNAL_GLOB \ / ASH_RANDOM_SUPPORT --BASH_IS_ASH <- [...] So all ash options would now be indented under "ash". [1] "Documentation/kbuild/kconfig-language.txt" in Linux kernel source Signed-off-by: Kang-Che Sung <explorer09@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* shell: clarify help text of CONFIG_{SH,BASH}_IS_* optionsKang-Che Sung2017-01-041-1/+22
| | | | | | | | | | | | | Mention the behavior if user selects CONFIG_SH_IS_ASH but not CONFIG_ASH. We will be explicit that invocations like "busybox ash" will not work for such configuration. Also clarify help text of CONFIG_BASH_IS_* that bash compatibility in ash is not complete. (It shouldn't be anyway - ash can't support every bash quirk out there.) Signed-off-by: Kang-Che Sung <explorer09@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hush: correct exitcode for unterminated ')' - exitcode2.tests testcaseDenys Vlasenko2017-01-031-2/+7
| | | | | | | function old new delta parse_stream 2595 2609 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>