[PATCH] [EVAL] Force fork if any trap is set, not just on EXIT.

2010-05-14 Thread Jilles Tjoelker
; kill $!;wait' This should print moo after 3 seconds. Example: dash -c '{ trap echo moo TERM; (sleep 3) } sleep 1; kill $!;wait' The same. Example: dash -c '{ trap echo moo TERM; sleep 3; :; } sleep 1; kill $!;wait' This works correctly even without this patch. Signed-off-by: Jilles Tjoelker

Re: wait regression in 3800d4

2010-05-22 Thread Jilles Tjoelker
was aborted by SIGCHLD (even though no CHLD trap has been set); however only on an SMP system. (This is on FreeBSD; I hacked mksignames.c to compile and work, although realtime signals are missing.) -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body

Re: [PATCH 1/4] [VAR] Add localvars nesting

2010-05-26 Thread Jilles Tjoelker
, which will work outside functions.) -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH 4/4] [VAR] Replace cmdenviron with localvars

2010-05-26 Thread Jilles Tjoelker
to the temporary regular-builtin scope. I suppose only functions should induce scope for 'local', such that things like command eval 'local i' continue to create a variable local to the function. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message

debian patches to exit with code 127 for nonexistent/directory scripts

2010-06-05 Thread Jilles Tjoelker
'command .' should do, but is very clear that failure to find/read a dot script shall not cause an interactive shell to exit. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord...@vger.kernel.org More majordomo info at http

Re: trap bug in recent versions of dash

2010-08-15 Thread Jilles Tjoelker
the script. With dash 0.5.5.1 it works as expected. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: trap bug in recent versions of dash

2010-08-22 Thread Jilles Tjoelker
On Mon, Aug 16, 2010 at 01:52:56PM +0200, Guido Berhoerster wrote: * Jilles Tjoelker jil...@stack.nl [2010-08-15 22:05]: On Wed, Aug 11, 2010 at 10:06:16AM +0200, Guido Berhoerster wrote: with the latest git version of dash trap actions are not evaluated in the context of a function. I

Re: [Partial patch] IFS and read builtin

2010-08-22 Thread Jilles Tjoelker
,,| { IFS=', ' read a b c; echo x${a}x${b}x${c}x; } These should result in: x1x2x3x x1x2x3,,x bash and ksh93 agree on this. However, dash master prints: x1x2x3,x x1x2x3,,x -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord

Re: [Partial patch] IFS and read builtin

2010-08-24 Thread Jilles Tjoelker
On Tue, Aug 24, 2010 at 12:51:47AM +0200, Harald van Dijk wrote: On 23/08/10 21:35, Jilles Tjoelker wrote: I think you should do what you think is best for the stability of your product. Because dash releases are not extensively tested, I'd recommend a trial build of at least a minimal base

Re: read() builtin doesn't read integer value /proc files (but bash's does)

2010-09-04 Thread Jilles Tjoelker
On Sat, Sep 04, 2010 at 08:20:33PM +0200, Steve Schnepp wrote: 2010/9/3 Jilles Tjoelker jil...@stack.nl: This patch assumes that the file descriptor is discarded afterwards (its position does not matter). Therefore the very common construct  while read x; do    ...  done stops working

[PATCH] [BUILTIN] Fix various issues with read by importing the NetBSD/FreeBSD code.

2010-09-07 Thread Jilles Tjoelker
This reverts the change to make read use the code from expand.c. Although read's splitting is similar to the splitting done as part of word expansions, the differences appear to add more complexity than the common code saves. The new code is from FreeBSD (which was originally taken from NetBSD).

Re: [PATCH] fix UTF-8 issues in read() builtin

2010-09-07 Thread Jilles Tjoelker
separate code instead of trying to use expand.c). Backslash escaping works too although I have just found some bugs with corner cases. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord...@vger.kernel.org More majordomo info at http

Re: bug with - under ulimit -n

2010-10-27 Thread Jilles Tjoelker
consider both behaviours valid and shell script that depends on either of them broken. They both have historical basis and their own advantages and disadvantages. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord...@vger.kernel.org

Re: Quoted closing brace in variable default expansion

2010-11-13 Thread Jilles Tjoelker
, for example. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

[PATCH] [REDIR] Replace GPL noclobberopen code with the FreeBSD version.

2010-11-20 Thread Jilles Tjoelker
Replace noclobberopen() from bash with the FreeBSD code for noclobber opens. This also reduces code size by eliminating an unnecessary check. --- src/redir.c | 77 +++--- 1 files changed, 15 insertions(+), 62 deletions(-) diff --git

Re: read() builtin doesnt read integer value /proc files (but bashs does)

2010-12-18 Thread Jilles Tjoelker
On Wed, Dec 15, 2010 at 12:55:51PM -0600, Jonathan Nieder wrote: Cristian Ionescu-Idbohrn wrote: On Sun, 28 Nov 2010, Herbert Xu wrote: On Sat, Sep 04, 2010 at 07:35:04PM +, Jilles Tjoelker wrote: This discarding is still bad as it throws away valid data if the open file description

Re: shift fatal error

2011-03-15 Thread Jilles Tjoelker
of accepting arithmetic expressions because that requires a subtly different kind of arithmetic expression without octal constants. POSIX is clear that 'shift 010' should shift ten positions, not eight, while 'shift $((010))' should shift eight positions. -- Jilles Tjoelker -- To unsubscribe from

Re: Porting dash to OpenBSD

2011-07-03 Thread Jilles Tjoelker
portability problems already; the code in master has different options. This is so even though nl is in SUSv4 under the XSI option. We already use awk so that should be safer. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord

Re: 'continue' does not work in files sourced with dotcmd

2011-07-10 Thread Jilles Tjoelker
On Sat, Jul 09, 2011 at 10:07:30PM +0800, Herbert Xu wrote: On Sat, Jul 09, 2011 at 03:07:04PM +0200, Jilles Tjoelker wrote: A fix for dash is below. The dash code is broken in a different way than the FreeBSD sh code was, but the patched code is pretty much the same. This makes the above

Re: evaluation of env variables in DASH

2011-10-19 Thread Jilles Tjoelker
may start with '-' or contain '\'. In this case, printf '%s\n' $A This has been asked/reported more frequently and the answer has been that it will not be changed. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord

Re: Question about job control in non-interactive shells

2012-01-13 Thread Jilles Tjoelker
, but dash calls kill() on a process group that is guaranteed not to exist. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH] var.c: check for valid variable name before printing in export -p

2012-02-25 Thread Jilles Tjoelker
/compatibility reasons. I did something similar to the OP's patch in FreeBSD (SVN r223183): set and export -p skip variables with invalid names. Note that this problem cannot occur with readonly -p because only variables with a proper name can be marked read-only. -- Jilles Tjoelker -- To unsubscribe

Re: wait and ctrl+Z

2012-05-03 Thread Jilles Tjoelker
traps that resume execution of the original script (i.e. do not exit the process). Otherwise, if 'wait' is being called without parameters, you can do something like until wait; do :; done If 'wait' is being called with parameters, the required loop is very complicated. -- Jilles Tjoelker

Re: [PATCH] implement privmode support in dash

2013-08-22 Thread Jilles Tjoelker
. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Fwd: bug? Spawned childs always remain in zombie state

2013-08-23 Thread Jilles Tjoelker
shells call waitpid() or similar from a SIGCHLD handler; this reaps zombies faster at the cost of more complex code (signal handler performing non-trivial work). -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord...@vger.kernel.org

Re: exec command and error checking

2014-01-28 Thread Jilles Tjoelker
). Dash implements the latter and I think it is more useful. Note that the two behaviours are indistinguishable if a single simple command is entered. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord...@vger.kernel.org More

Re: Possibly wrong handling of $_?

2014-12-25 Thread Jilles Tjoelker
in the makefile misbehaving only under Debian (where dash is used as /bin/sh) but not under systems. Such a principle of least surprise is not a design goal for dash. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord

Re: getopts doesn't properly update OPTIND when called from function

2015-06-01 Thread Jilles Tjoelker
, but it may not be desirable to change getopts to work that way. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: shell: dash - large file support

2015-07-26 Thread Jilles Tjoelker
, finding a dot script (. special builtin) and some related to the current directory. On another note, test -nt/-ot should really compare the nanoseconds parts as well. -- Jilles Tjoelker -- To unsubscribe from this list: send the line unsubscribe dash in the body of a message to majord

Re: [PATCH 2/2] histedit: Remove non-glibc fallback code

2016-08-08 Thread Jilles Tjoelker
On Thu, Aug 04, 2016 at 05:59:08PM +0200, Jilles Tjoelker wrote: > >From 23da600dcff616662a93f307420d9142598e2cae Mon Sep 17 00:00:00 2001 > From: Jilles Tjoelker <jil...@stack.nl> > Date: Thu, 4 Aug 2016 17:51:12 +0200 > Subject: [PATCH 1/2] [HISTEDIT] Stop depending on

Re: why does dash save, dup, and restore redirected descriptor in the parent, rather than redirect in the child?

2017-02-03 Thread Jilles Tjoelker
LL); > > } > What happens if open64 fails? How should the child inform the parent > of this specific error? In general, you are right, but in the shell's case there is no difficulty. The error is reported via an error message to stderr and a non-zero exit status of the command, and the child pr

Re: [PATCH] Don't execute binary files if execve() returned ENOEXEC.

2017-02-08 Thread Jilles Tjoelker
On Wed, Feb 08, 2017 at 09:02:33AM +0100, Adam Borowski wrote: > On Tue, Feb 07, 2017 at 11:52:08PM +0100, Jilles Tjoelker wrote: > > On Tue, Feb 07, 2017 at 09:33:07AM +0100, Adam Borowski wrote: > > > Both "dash -c foo" and "./foo" are supposed

Re: Parameter expansion, patterns and fnmatch

2016-09-02 Thread Jilles Tjoelker
de as possible, this seems, however, unhelpful. Since a pattern like *[ should match the literal string *[ in the choice where brackets that do not introduce a bracket expression are supposed to disable other special characters and any earlier work on the * is therefore wrong, implementi

Re: [BUG] regression in builtin echo

2016-09-02 Thread Jilles Tjoelker
On Fri, Sep 02, 2016 at 10:19:12PM +0800, Herbert Xu wrote: > On Fri, Sep 02, 2016 at 04:16:31PM +0200, Jilles Tjoelker wrote: > > Unlike Harald van Dijk's patch, the above patch breaks \c. Per POSIX > > (XSI option), \c shall cause all characters following it in the > > ar

Re: declaration utilities (was: [bug-diffutils] bug#24116: [platform-testers] new snapshot available: diffutils-3.3.50-0353)

2016-08-23 Thread Jilles Tjoelker
rbids special quoting rules for export and readonly, making this change sooner rather than later will be helpful to users. Looking at ChangeLog.O, I can see dash had special quoting rules for export, readonly and local between 1997 and 2001. They were removed, basically, because there was no sp

Re: [PATCH] trap: fix memory leak in exitshell()

2016-11-22 Thread Jilles Tjoelker
EXIT trap in dash). You can probably use the exception handling already present in the function to fix this. Note that ckfree() should only be used while INTOFF is in effect, both to avoid longjmp'ing out of free() and to ensure exactly one free in the presence of interruptions and errors. --

Re: Small cleanup to src/dash.1 - Command Line Editing

2017-06-23 Thread Jilles Tjoelker
, just like it avoids "you". The reference to the "later document" can probably be removed as well, since said document does not exist yet after many years. -- Jilles Tjoelker -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [BUG] quoted substring parameter expansion ignores single-quotes in the arg

2017-10-21 Thread Jilles Tjoelker
-/=/? and #/##/%/%% varieties in the parser. Not maintaining state for eacg nesting level makes the parser more elegant, but it is untenable since there is no way one can parse both "${v+'}" and "${v#'*'}" correctly without it. -- Jilles Tjoelker -- To unsubscribe from this list:

Re: builtin: Mark more regular built-ins

2018-05-15 Thread Jilles Tjoelker
ionale is that pwd should have been here since long ago (because it is in the list in XCU 2.9.1.1 Command Search and Execution), while the other three are new in SUSv4tc2. -- Jilles Tjoelker -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to ma

Re: exec: Stricter pathopt parsing

2018-05-15 Thread Jilles Tjoelker
ative to hash -r that does not need the XSI option. -- Jilles Tjoelker -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [v2 PATCH] expand: Escape minus sign in arithmetic expansion

2018-05-31 Thread Jilles Tjoelker
s negation overflows if result is INTMAX_MIN, leading to undefined behaviour. Perhaps leave the memtodest call but use STADJUST to remove the minus sign itself, leaving only the CTLESC or nothing. > + len++; > + } > + > + len += cvtnum(result); > >

Re: [BUG] $PATH not fully searched

2018-01-10 Thread Jilles Tjoelker
ngly recommend quoting it since some shells such as dash do not implement the special rule for assignment utilities yet. -- Jilles Tjoelker -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-27 Thread Jilles Tjoelker
They do what they do because > they have broken POSIX because they always treat backslashes that > arise from parameter expansion as literal backslashes. Let's use clear terminology: if it affects behaviour, it is by definition not an optimization. It is a special case for words not

Re: [PATCH 4/5] Stop using deprecated function sigsetmask()

2018-10-16 Thread Jilles Tjoelker
important than making the executable as small as possible, but the maintainer may not agree. -- Jilles Tjoelker

Re: [PATCH] Use a real non-cryptographic hash algorithm

2018-11-16 Thread Jilles Tjoelker
and they are not in the public domain > like FNV-1a. > [snip] > +hashval = (hashval ^ (unsigned char)*p++) * FNV_PRIME; > [snip] > +hashval = (hashval ^ (unsigned char)*p++) * FNV_PRIME; > [snip] > +hashval = (hashval ^ (unsigned char) *p++) + FNV_PRIME; I suppose this latter one should be * instead of + as well? -- Jilles Tjoelker

Re: [PATCH 1/6] exec: Don't execute binary files if execve() returned ENOEXEC.

2018-09-11 Thread Jilles Tjoelker
return 0; > + } > + return 0; > +} > + > + > STATIC void > tryexec(char *cmd, char **argv, char **envp) > { > @@ -162,6 +192,8 @@ repeat: > execve(cmd, argv, envp); > #endif > if (cmd != path_bshell && errno == ENOEXEC) { > + if (file_is_binary(cmd)) > + return; > *argv-- = cmd; > *argv = cmd = path_bshell; > goto repeat; -- Jilles Tjoelker

Re: [v2 PATCH] eval: Reset handler when entering a subshell

2019-03-03 Thread Jilles Tjoelker
fairly old dash v0.5.9.1 I tried works even differently, writing an error message (to stderr) followed by a. So it first continues after the error and then aborts when '.' ends. This seems clearly broken (but I think things have changed since back then). -- Jilles Tjoelker

Re: shell: Always use explicit large file API

2020-05-09 Thread Jilles Tjoelker
interfaces selectively, so that the binary could be a bit smaller by avoiding 64-bit numbers where they were not necessary. Now that the feature "supports files with inode numbers that do not fit in 32 bits" is considered essential, this complexity seems unnecessary. I'm sorry for not providing a patch. -- Jilles Tjoelker

Re: [PATCH] jobs: Block signals during tcsetpgrp

2021-01-06 Thread Jilles Tjoelker
semaphore or MAP_SHARED mapping might cause unexpected issues in strange use cases. A related bug: if fork fails for a command substitution, the pipe created for reading the command output remains open (two descriptors). This one is also in dash as well as FreeBSD sh. Throwing exceptions from forkshell() may not be the best idea. -- Jilles Tjoelker

Re: dash 0.5.11.2, busybox sh 1.32.0, FreeBSD 12.2 sh: spring TTOU but should not i think

2020-12-24 Thread Jilles Tjoelker
On Wed, Dec 23, 2020 at 08:18:24PM +, Harald van Dijk wrote: > On 21/12/2020 16:24, Jilles Tjoelker wrote: > > Also, simply entering the command > > trap "echo TTOU" TTOU > > in an interactive shell makes it behave strangely. Created jobs > > immedi

Re: dash 0.5.11.2, busybox sh 1.32.0, FreeBSD 12.2 sh: spring TTOU but should not i think

2020-12-21 Thread Jilles Tjoelker
nyway since the shell must perform tcsetpgrp() from the background when a foreground job has terminated. What is definitely required, though, is that the shell not read input or alter terminal settings if it is started in the background (possibly unless the script explicitly ignored SIGTTOU). This is what the loop with tcgetpgrp() does. -- Jilles Tjoelker

Re: getopts appears to not be shifting $@ when consuming options

2021-01-29 Thread Jilles Tjoelker
round would be to use that code to construct the attr="$OPTARG" list. If your actual code is more like: set -- -a foo -a bar # for testing while getopts :a: arg; do ... then the script violates the rule I mentioned, and has unspecified results. -- Jilles Tjoelker