Re: eval '<$(;)' causes Segmentation Fault

2024-08-27 Thread Chet Ramey
On 8/26/24 10:57 PM, Zachary Santer wrote: Bash Version: 5.3 Patch Level: 0 Release Status: alpha This is devel, commit 2e01122fe7. Really don't get what's going on here: You have two instances of the shell fighting over terminal input. -- ``The lyf so short, the craft so long to lerne.'' -

Re: eval '<$(;)' causes Segmentation Fault

2024-08-27 Thread Chet Ramey
On 8/26/24 6:44 PM, youheng@gmail.com wrote: Bash Version: 5.3 Patch Level: 0 Release Status: alpha POC: $ cat poc.sh eval '<${;}' The specific case is an empty command containing only a redirection that results in an expansion error read from a script or string. I can con

Re: eval '<$(;)' causes Segmentation Fault

2024-08-27 Thread Chet Ramey
On 8/26/24 9:52 PM, Dale R. Worley wrote: writes: Repeat-By: 1. Create a script, i.e. `poc.sh` with the problematic string 2. Execute `bash poc.sh` Interestingly, when I run it (bash 5.1.0(1), which is pretty old), I don't get the seg fault when I enter that string from the

Re: eval '<$(;)' causes Segmentation Fault

2024-08-26 Thread Zachary Santer
On Sun, Aug 25, 2024 at 8:57 PM wrote: > > All the following scripts can create a Segmentation Fault > > eval '<$[;]' > > eval '<$(;)' > > eval '<${;}' > > eval '<$[|]&#

Re: eval '<$(;)' causes Segmentation Fault

2024-08-26 Thread Dale R. Worley
writes: > Repeat-By: > 1. Create a script, i.e. `poc.sh` with the problematic string > 2. Execute `bash poc.sh` Interestingly, when I run it (bash 5.1.0(1), which is pretty old), I don't get the seg fault when I enter that string from the keyboard, only when it's read from a scrip

RE: eval '<$(;)' causes Segmentation Fault

2024-08-26 Thread youheng.lue
r: gcc Compilation CFLAGS: -g -O2 uname output: Linux 839141c7e5ba 6.8.0-40-generic #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 x86_64 Linux Machine Type: x86_64-pc-linux-musl Bash Version: 5.3 Patch Level: 0 Release Status: alpha POC: $ cat poc.sh eval '<${;}'

Re: eval '<$(;)' causes Segmentation Fault

2024-08-26 Thread Chet Ramey
can create a Segmentation Fault eval '<$[;]' eval '<${;}' eval '<$[|]' These still cause the current devel branch to segfault, but (at least for me, on macOS) only when invoked via argument, as OP directed. For example, reading th

Re: eval '<$(;)' causes Segmentation Fault

2024-08-25 Thread Lawrence Velázquez
tation Fault > > eval '<$[;]' > eval '<${;}' > eval '<$[|]' These still cause the current devel branch to segfault, but (at least for me, on macOS) only when invoked via argument, as OP directed. For example, reading the scripts via stdin

eval '<$(;)' causes Segmentation Fault

2024-08-25 Thread youheng.lue
From: Youheng Lü To: bug-bash@gnu.org Subject: eval '<$(;)' causes Segmentation Fault Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -flto=auto -ffat-lto-objects -flto=auto -ffa

Re: eval '`' reports error but $? is still 0

2023-05-10 Thread Emanuele Torre
On Wed, May 10, 2023 at 09:05:20PM +0800, Clark Wang wrote: > See the following example (with 5.2.15): > > bash-5.2$ PS1='$? >> ' > 0 >> eval '`' > bash: unexpected EOF while looking for matching ``' > 0 >><-- press ENTER >

eval '`' reports error but $? is still 0

2023-05-10 Thread Clark Wang
See the following example (with 5.2.15): bash-5.2$ PS1='$? >> ' 0 >> eval '`' bash: unexpected EOF while looking for matching ``' 0 >><-- press ENTER 2 >> <-- now $? is 2 It looks like the failed eval '`' is still waiting for some input?

Re: pop_var_context msg when eval code with errexit set

2022-10-13 Thread Chet Ramey
On 10/12/22 10:25 AM, Chet Ramey wrote: Then run this test script with 'errexit' option set: $ ./bash -e test_script test_script: line 5: pop_var_context: head of shell_variables not a function context It's an internal message warning that something might be wrong. We'll see if

Re: pop_var_context msg when eval code with errexit set

2022-10-12 Thread Chet Ramey
On 10/12/22 12:58 AM, Xavier Delaruelle wrote: Bash Version: 5.2 Patch Level: 2 Release Status: release Description: Starting version 5.2, when evaluating bash code (with eval builtin command) with 'errexit' option set, a pop_var_context message appears if the evaluating code l

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-12 Thread Alex fxmbsw7 Ratchev
isting features, why add one more? > > > > [...] With your syntax you still have to be aware of what's > > in that trap [...] > > > > Not really. If, for some reason, I didn't know what's in that trap and were > super paranoiac about it, I could do &g

pop_var_context msg when eval code with errexit set

2022-10-11 Thread Xavier Delaruelle
-linux-gnu Bash Version: 5.2 Patch Level: 2 Release Status: release Description: Starting version 5.2, when evaluating bash code (with eval builtin command) with 'errexit' option set, a pop_var_context message appears if the evaluating code leads to an error: test_scri

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-08 Thread Cynthia Coan
o miss that next thing that isn't `defer` as it comes up. > > I'm not saying > > defer necessarily meets the same bar as usefulness, but I think it'd > > be wrong to dismiss new features just because they can be accomplished > > today, with relatively few lines. >

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-08 Thread Koichi Murase
ing > defer necessarily meets the same bar as usefulness, but I think it'd > be wrong to dismiss new features just because they can be accomplished > today, with relatively few lines. In my point of view, the suggested "new" feature is *already implemented in Bash as th

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-08 Thread Oğuz
to be aware of what's > in that trap [...] > Not really. If, for some reason, I didn't know what's in that trap and were super paranoiac about it, I could do oldaction=$(trap -P EXIT) trap 'eval "$oldaction"; bar' EXIT I've never been in su

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-08 Thread Cynthia Coan
with relatively few lines. If we find something lots of people are doing, it might be worth discussing adding it in (and again: I'm totally willing to admit defer/defer-like might not meet that bar)! > Could you describe it in more detail or could you provide an example > of how this can

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-08 Thread Koichi Murase
Hi Lawrence, 2022年10月8日(土) 16:04 Lawrence Velázquez : > On Sat, Oct 8, 2022, at 2:11 AM, Koichi Murase wrote: > > [...]. One thing to note is that the RETURN trap > > should be cleaned up inside the RETURN trap itself by running `trap - > > RETURN', or otherwise the RETURN trap is erroneously cons

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-08 Thread Koichi Murase
Let me update the example implementation of ``defer''. I think this is more readable: function defer { local trap eval "trap=($(trap -p RETURN))" trap -- " if [[ \$FUNCNAME != defer ]]; then trap - RETURN $1 ${trap[2]-} fi" RETURN } de

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-08 Thread Koichi Murase
util.hook.sh#L42-L61 > (yours > in particular can mess up with certain quoting rules, but is nothing a > quick sed can't fix). Could you describe it in more detail or could you provide an example of how this can mess up? For example, the quoting of the trap string in the output of `tr

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-08 Thread Lawrence Velázquez
On Sat, Oct 8, 2022, at 2:11 AM, Koichi Murase wrote: > 2022年10月8日(土) 12:04 Cynthia Coan : >> [...] >> >> Otherwise, I think we can perhaps reword this into two smaller >> features: "function local trap signals", > > The existing RETURN trap is exactly the trap that can be used to clean > up resour

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-08 Thread Cynthia Coan
> I don't think this would be a feature worth the time to implement and > the complexity it would introduce. Is there any other use case for this > than cleaning up temporary files on function return? Yeah! I think that's a fair point since it seems like we're landing on traps being the way forwar

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-07 Thread Cynthia Coan
, be careful that the function > needs to be marked with the trace attribute by ``declare -ft > ''. Also, the RETURN trap needs to be suppressed for > such a function itself. I haven't really tested it but something like > this should work as you expect: > &g

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-07 Thread Koichi Murase
to perform that. In that case, be careful that the function needs to be marked with the trace attribute by ``declare -ft ''. Also, the RETURN trap needs to be suppressed for such a function itself. I haven't really tested it but something like this should work as you expect: function

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-07 Thread Oğuz İsmail Uysal
On 10/8/22 6:03 AM, Cynthia Coan wrote: Otherwise, I think we can perhaps reword this into two smaller features: "function local trap signals", and I don't think this would be a feature worth the time to implement and the complexity it would introduce. Is there any other use case for this than

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-07 Thread Cynthia Coan
I definitely got the inspiration of the name from the Go programming language. There are several other languages who use similar concepts when dealing with cleanup where something like an RAII pattern to free resources. It sounds like we're leaning towards trap, over a new built-in which I think i

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-07 Thread Dale R. Worley
The Go programming language has a "defer" statement which is used considerably for exactly this purpose. So we know that it's useful in practice. The question remains what is a good way to introduce it into Bash. As others have noted, there is already a "trap" with similar functionality. I'm no

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-06 Thread Cynthia Coan
e" with the existing practices. I still think defer might be more simple, but that is just my opinion! I think both are totally workable. - Cynthia On Thu, Oct 6, 2022 at 4:05 PM Lawrence Velázquez wrote: > > On Thu, Oct 6, 2022, at 4:08 PM, Cynthia Coan wrote: > > I'd specific

Re: feature request: new builtin `defer`, scope delayed eval

2022-10-06 Thread Lawrence Velázquez
On Thu, Oct 6, 2022, at 4:08 PM, Cynthia Coan wrote: > I'd specifically like to propose a new built-in called `defer` which > acts like `eval` however is not parsed/expanded/run until it's scope > is leaving. Hopefully "scope" is the correct word, I'm imagini

feature request: new builtin `defer`, scope delayed eval

2022-10-06 Thread Cynthia Coan
Hey all, I've started working on this idea, and before getting too far I'd like to get general feedback on the feature before going too far. I'd specifically like to propose a new built-in called `defer` which acts like `eval` however is not parsed/expanded/run until it

Re: Line counting is ideosyncratic with eval.

2021-09-24 Thread Chet Ramey
On 9/22/21 2:27 PM, dfsm...@us.ibm.com wrote: Bash Version: 5.0 Patch Level: 3 Release Status: release Description: When running commands through eval, the script's line counter is incremented, even though the eval line is fixed. Thanks for the report. This is a trick

Line counting is ideosyncratic with eval.

2021-09-22 Thread dfsmith
output: Linux porter 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 5.0 Patch Level: 3 Release Status: release Description: When running commands through eval, the script's line counter is incremented,

Re: [PATCH] Bash 5.0+: Fix a problem that interactive sessions close with `eval {'

2020-08-31 Thread Chet Ramey
On 8/27/20 8:33 PM, Koichi Murase wrote: > Bash Version: 5.1 > Patch Level: 0 > Release Status: release > > Description: > > When a command string with an incomplete construct is supplied to > the `eval' builtin in interactive sessions, the process will be &

[PATCH] Bash 5.0+: Fix a problem that interactive sessions close with `eval {'

2020-08-27 Thread Koichi Murase
-linux-gnu Bash Version: 5.1 Patch Level: 0 Release Status: release Description: When a command string with an incomplete construct is supplied to the `eval' builtin in interactive sessions, the process will be terminated. This does not happen before Bash 5.0. This does not happen i

Re: backquote peculiarities (was: Re: Combination of "eval set -- ..." and $() command substitution is slow)

2019-07-16 Thread Chet Ramey
On 7/15/19 6:19 PM, astian wrote: >> I doubt it makes any difference to the timing, which I think >> Chet has already answered, but it is worth pointing out that these >> two commands ... >> >> printf '%s\n' "`printf %s "$i"`" >> printf '%s\n' "$(printf %s

Re: Combination of "eval set -- ..." and $() command substitution is slow

2019-07-16 Thread Andreas Schwab
On Jul 16 2019, Ilkka Virta wrote: > On 15.7. 20:49, Robert Elz wrote: > >> printf '%s\n' "`printf %s "$i"`" >> printf '%s\n' "$(printf %s "$i")" >> >> aren't actually the same. In the first $i is unquoted, in the second it is >> quoted. > > Huh, rea

Re: Combination of "eval set -- ..." and $() command substitution is slow

2019-07-16 Thread Ilkka Virta
On 15.7. 20:49, Robert Elz wrote: printf '%s\n' "`printf %s "$i"`" printf '%s\n' "$(printf %s "$i")" aren't actually the same. In the first $i is unquoted, in the second it is quoted. Huh, really? It looks to me like the first one treats $i

backquote peculiarities (was: Re: Combination of "eval set -- ..." and $() command substitution is slow)

2019-07-15 Thread astian
Robert Elz: > Date:Wed, 10 Jul 2019 17:21:00 + > From:astian > Message-ID: > > I doubt it makes any difference to the timing, which I think > Chet has already answered, but it is worth pointing out that these > two commands ... > > printf '

Re: Combination of "eval set -- ..." and $() command substitution is slow

2019-07-15 Thread Robert Elz
Date:Wed, 10 Jul 2019 17:21:00 + From:astian Message-ID: I doubt it makes any difference to the timing, which I think Chet has already answered, but it is worth pointing out that these two commands ... printf '%s\n' "`printf %s "$i"`"

Re: Combination of "eval set -- ..." and $() command substitution is slow

2019-07-15 Thread Chet Ramey
On 7/13/19 1:36 PM, astian wrote: > Chet Ramey: >>> - $() seems generally slightly slower than ``, but becomes >>> pathologically >>> so when preceded with "eval set -- ...". >> >> It is slightly slower -- POSIX requires that the she

Re: Combination of "eval set -- ..." and $() command substitution is slow

2019-07-13 Thread astian
(probably not very useful, feel free to ignore them). Chet Ramey: >> - $() seems generally slightly slower than ``, but becomes pathologically >> so when preceded with "eval set -- ...". > > It is slightly slower -- POSIX requires that the shell parse

Re: Combination of "eval set -- ..." and $() command substitution is slow

2019-07-12 Thread Chet Ramey
On 7/10/19 1:21 PM, astian wrote: > Bash Version: 5.0 > Patch Level: 3 > Release Status: release > > Description: > > I discovered a curious performance degradation in the combined usage of the > constructs "eval set -- ..." and new-style command substi

Combination of "eval set -- ..." and $() command substitution is slow

2019-07-10 Thread astian
: Linux $nodename 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 5.0 Patch Level: 3 Release Status: release Description: I discovered a curious performance degradation in the combined usage of the constructs "eva

Re: `eval` pollutes the history when it runs "set -o history"

2019-06-11 Thread Chet Ramey
On 6/11/19 10:07 AM, Andreas Schwab wrote: > On Jun 11 2019, Chet Ramey wrote: > >> Maybe. But the user-visible option that says whether or not to save >> commands in the history is decoupled from the internal set of flags that >> control it. The option should remain visibly on unless the user tu

Re: `eval` pollutes the history when it runs "set -o history"

2019-06-11 Thread Andreas Schwab
On Jun 11 2019, Chet Ramey wrote: > Maybe. But the user-visible option that says whether or not to save > commands in the history is decoupled from the internal set of flags that > control it. The option should remain visibly on unless the user turns it > off, even if saving commands in the histo

Re: `eval` pollutes the history when it runs "set -o history"

2019-06-11 Thread Chet Ramey
o history" should >>> have no effect; yet lines before are not recorded, and lines >>> after are recorded. >> >> Bash temporarily stops recording commands in the history when you use >> `eval', but if you turn history back on explicitly using `set

Re: `eval` pollutes the history when it runs "set -o history"

2019-06-11 Thread _y
t; yet lines before are not recorded, and lines >> after are recorded. > > Bash temporarily stops recording commands in the history when you use > `eval', but if you turn history back on explicitly using `set -o history', > it will honor that. In that case, shouldn’t `eva

Re: `eval` pollutes the history when it runs "set -o history"

2019-06-10 Thread Chet Ramey
On 6/8/19 3:41 PM, _...@crans.org wrote: > Bash Version: 5.0 > Patch Level: 7 > Release Status: release > > Description: > When `eval` runs "set -o history", subsequent lines in the > eval-ed string are recorded in the history. Yes. History doesn&#x

`eval` pollutes the history when it runs "set -o history"

2019-06-08 Thread _y
rsion: 5.0 Patch Level: 7 Release Status: release Description: When `eval` runs "set -o history", subsequent lines in the eval-ed string are recorded in the history. This breaks the following coding pattern: saved_options="$(set +o)" #

Re: 'eval' exit behaviour in posix mode

2018-12-26 Thread Chet Ramey
On 12/23/18 7:42 PM, Martijn Dekker wrote: > Op 14-12-18 om 14:29 schreef Chet Ramey: >> On 12/14/18 6:46 AM, Martijn Dekker wrote: >>> In current git, 'bash -o posix' no longer exits the shell on a syntax error >>> in the argument to the special built

Re: 'eval' exit behaviour in posix mode

2018-12-23 Thread Martijn Dekker
Op 14-12-18 om 14:29 schreef Chet Ramey: On 12/14/18 6:46 AM, Martijn Dekker wrote: In current git, 'bash -o posix' no longer exits the shell on a syntax error in the argument to the special builtin 'eval'. Bash 4.2-4.4 exit as POSIX specifies. Well, not quite. It'

Re: 'eval' exit behaviour in posix mode

2018-12-14 Thread Chet Ramey
On 12/14/18 6:46 AM, Martijn Dekker wrote: > In current git, 'bash -o posix' no longer exits the shell on a syntax error > in the argument to the special builtin 'eval'. Bash 4.2-4.4 exit as POSIX > specifies. Well, not quite. It's the specific case of an une

'eval' exit behaviour in posix mode

2018-12-14 Thread Martijn Dekker
In current git, 'bash -o posix' no longer exits the shell on a syntax error in the argument to the special builtin 'eval'. Bash 4.2-4.4 exit as POSIX specifies. $ bash -o posix -c 'eval "(" || echo woops' bash: eval: regel 1: syntaxfout: onverwacht best

Re: [BUG] RETURN trap with -o functrace: infinite recursion on 'eval return'

2018-04-15 Thread Chet Ramey
On 4/13/18 11:29 PM, Martijn Dekker wrote: > Op 14-04-18 om 03:49 schreef Chet Ramey: >> On 4/10/18 5:56 AM, Martijn Dekker wrote: >>> It seems odd that the RETURN trap would be triggered while a RETURN trap >>> action is still being executed. Might it be better to temporarily >>> deactivate the ef

Re: [BUG] RETURN trap with -o functrace: infinite recursion on 'eval return'

2018-04-13 Thread Martijn Dekker
Op 14-04-18 om 03:49 schreef Chet Ramey: On 4/10/18 5:56 AM, Martijn Dekker wrote: It seems odd that the RETURN trap would be triggered while a RETURN trap action is still being executed. Might it be better to temporarily deactivate the effect of '-o functrace' while a RETURN trap action is bein

Re: [BUG] RETURN trap with -o functrace: infinite recursion on 'eval return'

2018-04-13 Thread Chet Ramey
On 4/10/18 5:56 AM, Martijn Dekker wrote: > $ bash -o functrace -c 'fn() { eval "return"; }; trap "fn" RETURN; fn' > > Result: segfault due to infinite recursion. Thanks for the report; I'll fix this. ______ > > Even apart from this b

[BUG] RETURN trap with -o functrace: infinite recursion on 'eval return'

2018-04-10 Thread Martijn Dekker
$ bash -o functrace -c 'fn() { eval "return"; }; trap "fn" RETURN; fn' Result: segfault due to infinite recursion. __ Even apart from this bug with 'eval return', the effect of '-o functrace' is a bit strange: $ bash -o functrace -c

Re: devel: 'eval' returns 0 upon syntax error

2017-06-18 Thread Chet Ramey
On 6/18/17 8:06 PM, Martijn Dekker wrote: > (eval '(');echo $? Thanks for the report. The parse error followed by EOF needs to call YYABORT when the shell isn't reading input interactively. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer

devel: 'eval' returns 0 upon syntax error

2017-06-18 Thread Martijn Dekker
bash-snap-20170616 $ (eval '(');echo $? bash: eval: line 2: syntax error: unexpected end of file 0 The exit status is 0, but should be 1. As far as I can trace it, this bug seems to have been introduced in bash-20170511 snapshot. - M.

Re: Odd LINENO behaviour in 'eval'

2017-03-20 Thread Chet Ramey
On 3/19/17 10:58 PM, Martijn Dekker wrote: > Test script: > printf "$LINENO " > printf "$LINENO " > eval 'printf "$LINENO " > printf "$LINENO " > printf "$LINENO " ' > printf "$LINENO\n"

Odd LINENO behaviour in 'eval'

2017-03-19 Thread Martijn Dekker
Test script: printf "$LINENO " printf "$LINENO " eval ' printf "$LINENO " printf "$LINENO " printf "$LINENO " ' printf "$LINENO\n" Output on various shells: bash: 1 2 5 6 7 6 (?!) {m,l,pd}ksh

Re: eval '' would exit an interactive shell

2015-10-01 Thread Chet Ramey
On 9/29/15 11:48 AM, 紫云飞 wrote: > $ eval '\' > exit > > I am wondering if this is a bug or intentional behavior. It's a bug in bash-4.3, already fixed for the next release. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer

eval '' would exit an interactive shell

2015-10-01 Thread 紫云飞
$ eval '\' exit I am wondering if this is a bug or intentional behavior.

Re: eval a=b\ c

2015-05-27 Thread Eduardo A . Bustamante López
identical results of setting a variable to a > value with a space in it? dualbus@hp ~ % for sh in bash zsh; do "$sh" -c 'echodo(){ echo "$*"; eval "$@"; }; echodo a=b\\ c; echo "$a"'; done a=b\ c b c a=b\ c b c -- Eduardo Bustamante https://dualbus.me/

Re: eval a=b\ c

2015-05-27 Thread Dave Yost
-26, at 1:04 AM, Andreas Schwab wrote: > > d...@yost.com writes: > >>eval$@ > > You are expanding a shell parameter unquoted. Never do that unless you > know what you are doing. > > eval "$@" > > Andreas. > > -- > Andre

Re: eval a=b\ c

2015-05-26 Thread Greg Wooledge
On Mon, May 25, 2015 at 12:33:53PM -0700, d...@yost.com wrote: > # Echo the arguments, then execute them as a command. > I can't find a way to implement echodo in bash. set -x your code set +x

Re: eval a=b\ c

2015-05-26 Thread Andreas Schwab
d...@yost.com writes: > eval$@ You are expanding a shell parameter unquoted. Never do that unless you know what you are doing. eval "$@" Andreas. -- Andreas Schwab, SUSE Labs, sch...@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7

Re: eval a=b\ c

2015-05-25 Thread Linda Walsh
Dennis Williamson wrote: I'm trying to put a command in a variable, but the complex cases always fail! : http://mywiki.wooledge.org/BashFAQ/050 Eval command and security issues : http://mywiki.wooledge.org/BashFAQ/048 Dunno, but I see nothing on that page about using printf -

Re: eval a=b\ c

2015-05-25 Thread Dennis Williamson
I'm trying to put a command in a variable, but the complex cases always fail! : http://mywiki.wooledge.org/BashFAQ/050 Eval command and security issues : http://mywiki.wooledge.org/BashFAQ/048 On Mon, May 25, 2015 at 2:33 PM, wrote: > Configuration Information [Automatically generated

Re: eval a=b\ c

2015-05-25 Thread Linda Walsh
64 #1 SMP Wed Apr 22 06:48:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-unknown-linux-gnu Bash Version: 4.3 Patch Level: 39 Release Status: release Description: # Echo the arguments, then execute them as a command. function echodo() { if [[ -n $ZSH_VERSION ]] ; then ec

Re: eval a=b\ c

2015-05-25 Thread Charles Daffern
On 25/05/15 20:33, d...@yost.com wrote: > if [[ -n $ZSH_VERSION ]] ; then > echo "[ ${(q)@} ]" > eval${(q)@} > else > echo "[ $@ ]" > eval$@ > fi I believe the bash equivalent here would be something along the lines of: qu

eval a=b\ c

2015-05-25 Thread dave
9 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-unknown-linux-gnu Bash Version: 4.3 Patch Level: 39 Release Status: release Description: # Echo the arguments, then execute them as a command. function echodo() { if [[ -n $ZSH_VERSION ]] ; then echo "[ ${(q)@} ]"

Re: Final backslash causes array assignment mis-parse in previous eval

2014-08-26 Thread Chet Ramey
d the message as > spam, > but if not, please accept my appoligies for the dup. > > \ is supposed to be effectively ignored, but if it appears at > the > end of the script then parse errors sometimes occur with previous > statements. > In partic

backslash at end of input causes eval parse error

2014-08-25 Thread jim . avera
_64-unknown-linux-gnu Bash Version: 4.3 Patch Level: 0 Release Status: release Description: A \ is supposed to be ignored, but if it occurs at the very end of the input then it causes a prior eval containing an array assignment to be mis-parsed. However if the eval contains something other th

Final backslash causes array assignment mis-parse in previous eval

2014-08-25 Thread jim . avera
for the dup. \ is supposed to be effectively ignored, but if it appears at the end of the script then parse errors sometimes occur with previous statements. In particular eval "array=(values...)" is mis-parsed if a subsequent statement ends with and there is n

Re: eval doesn't close file descriptor?

2013-02-17 Thread Chet Ramey
On 2/13/13 12:44 PM, Matei David wrote: > Another thing I tried was to open a fd with <() and use it later in a shell > function. Surprisingly, the fd disappears (is closed) if the shell executes > something unrelated in subshell: This was reported a while back http://lists.gnu.org/archive/html/b

Re: eval doesn't close file descriptor?

2013-02-13 Thread Matei David
et Ramey wrote: > >> On 2/12/13 11:40 AM, Pierre Gaston wrote: >> > On Tue, Feb 12, 2013 at 6:07 PM, Matei David >> wrote: >> > >> >> Ok, but I see the same behaviour when eval runs in a subshell: >> >> >> >> $ bash -c 'llfd (

Re: eval doesn't close file descriptor?

2013-02-13 Thread Matei David
Thank you for the explanation. On Tue, Feb 12, 2013 at 8:32 PM, Chet Ramey wrote: > On 2/12/13 11:40 AM, Pierre Gaston wrote: > > On Tue, Feb 12, 2013 at 6:07 PM, Matei David > wrote: > > > >> Ok, but I see the same behaviour when eval runs in a subshell: > >

Re: eval doesn't close file descriptor?

2013-02-12 Thread Chet Ramey
On 2/12/13 11:40 AM, Pierre Gaston wrote: > On Tue, Feb 12, 2013 at 6:07 PM, Matei David wrote: > >> Ok, but I see the same behaviour when eval runs in a subshell: >> >> $ bash -c 'llfd () { echo "pid:$BASHPID" >&2; ls -l /proc/$BASHPID/fd/ >&g

Re: eval doesn't close file descriptor?

2013-02-12 Thread Ken Irving
On Tue, Feb 12, 2013 at 04:22:08PM -0500, Matei David wrote: > Generally speaking, it took me quite some time to figure out how to > properly create a "double pipe" without using any intermediate files or > fifos. The concept is very easy: in -> tee -> two parallel, independent > pipes -> join -> o

Re: eval doesn't close file descriptor?

2013-02-12 Thread Chet Ramey
On 2/12/13 2:07 PM, Matei David wrote: OK. Let me try this again. One key to the explanations is that child processes inherit all of the parent's open file descriptors. > ... there seem to be not 2 but 3(!) types of file descriptors: > 1. fds which are copied across both subshells and exec; like

Re: eval doesn't close file descriptor?

2013-02-12 Thread Matei David
Hi Chet, Conceptually, the availability of a single flag "close-on-exec" (BTW, is there a way to check those flags in bash or using /proc?) should create only 2, not 3 types of file descriptors- that's what I find confusing. Does subprocess creation as in '(llfd)' entail an execve() call? My guess

Re: eval doesn't close file descriptor?

2013-02-12 Thread Chet Ramey
On 2/12/13 2:07 PM, Matei David wrote: > ... there seem to be not 2 but 3(!) types of file descriptors: > 1. fds which are copied across both subshells and exec; like 4 > 2. fds which are not copied across subshells; like 60&63 > 3. fds which are copied across subshells, but not exec; like 10 > >

Re: eval doesn't close file descriptor?

2013-02-12 Thread Matei David
So in other words, you're saying I should use '... | eval "exec $x>&-; llfd"' instead of '... | eval "llfd $x>&-"'. This way the subshell won't be assuming I might use $x later. That works, but I still find it counterintuitive th

Re: eval doesn't close file descriptor?

2013-02-12 Thread Matei David
hy would I want the fd in a variable otherwise.) Too bad the "natural" syntax 'llfd $x>&-' doesn't work, but I guess this will do. On Tue, Feb 12, 2013 at 11:12 AM, Greg Wooledge wrote: > On Tue, Feb 12, 2013 at 11:07:06AM -0500, Matei David wrote: > > On a d

Re: eval doesn't close file descriptor?

2013-02-12 Thread Pierre Gaston
On Tue, Feb 12, 2013 at 6:07 PM, Matei David wrote: > Ok, but I see the same behaviour when eval runs in a subshell: > > $ bash -c 'llfd () { echo "pid:$BASHPID" >&2; ls -l /proc/$BASHPID/fd/ > >&2; }; x=3; eval "exec $x>/dev/null"; llfd

Re: eval doesn't close file descriptor?

2013-02-12 Thread Greg Wooledge
On Tue, Feb 12, 2013 at 11:07:06AM -0500, Matei David wrote: > On a different but related note, I hate having to do eval to manipulate an > fd stored in a variable. Why doesn't 'llfd $x>&-' work, especially since > 'llfd >&$x' works just fi

Re: eval doesn't close file descriptor?

2013-02-12 Thread Matei David
Ok, but I see the same behaviour when eval runs in a subshell: $ bash -c 'llfd () { echo "pid:$BASHPID" >&2; ls -l /proc/$BASHPID/fd/ >&2; }; x=3; eval "exec $x>/dev/null"; llfd; echo | eval "llfd $x>&-"' [same output, fd 10 open

Re: eval doesn't close file descriptor?

2013-02-11 Thread Pierre Gaston
On Tue, Feb 12, 2013 at 1:54 AM, wrote: > With the script below, I'd expect any fd pointing to /dev/null to be > closed when the second llfd() is executed. Surprisingly, fd 3 is closed, > but fd 10 is now open, pointing to /dev/null, as if eval copied it instead > of closing

eval doesn't close file descriptor?

2013-02-11 Thread matei . david
With the script below, I'd expect any fd pointing to /dev/null to be closed when the second llfd() is executed. Surprisingly, fd 3 is closed, but fd 10 is now open, pointing to /dev/null, as if eval copied it instead of closing it. Is this a bug? Thanks, M $ bash -c 'llfd () { l

Re: Bug with `eval return' in .bashrc ?

2012-08-13 Thread Chet Ramey
On 8/10/12 3:05 AM, Clark WANG wrote: > For quite a long time I don't know why my bash stops remembering command > history. I just figured out it was caused by some code like `eval return' > in the .bashrc/.bash_profile. Thanks for the report. As you suspected, the combination

Bug with `eval return' in .bashrc ?

2012-08-10 Thread Clark WANG
For quite a long time I don't know why my bash stops remembering command history. I just figured out it was caused by some code like `eval return' in the .bashrc/.bash_profile. Steps to reproduce (tested with 3.2.25, 4.0.28, 4.1.11 and 4.2.29): $ cp .bashrc .bashrc.old $ echo e

Re: status on $[arith] for eval arith vsl $((arith))??

2012-04-12 Thread Andreas Schwab
Linda Walsh writes: > - YESTERDAY=$(date -r $((`date +%s` - 86400 )) +%d/%m/%Y This fails around autumn DST transition (assuming s/-r /-d @/). YESTERDAY=$(date -d '12:00 yesterday' +%d/%m/%Y) Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756

Re: status on $[arith] for eval arith vsl $((arith))??

2012-04-11 Thread Linda Walsh
Greg Wooledge wrote: On Wed, Apr 11, 2012 at 02:34:01AM -0700, Linda Walsh wrote: - for ((vl=$((v_level - 1)); $vl > 0; --vl)) The inside of the for ((...)) is already a math context. You don't need another $((...)) inside it. for ((vl = v_level - 1; vl > 0; --vl)) Or is that another "ir

Re: status on $[arith] for eval arith vsl $((arith))??

2012-04-11 Thread Greg Wooledge
On Wed, Apr 11, 2012 at 02:34:01AM -0700, Linda Walsh wrote: > - for ((vl=$((v_level - 1)); $vl > 0; --vl)) The inside of the for ((...)) is already a math context. You don't need another $((...)) inside it. for ((vl = v_level - 1; vl > 0; --vl)) Or is that another "irrelevant detail"?

Re: status on $[arith] for eval arith vsl $((arith))??

2012-04-11 Thread Linda Walsh
Chet Ramey wrote: On 4/9/12 9:07 PM, Linda Walsh wrote: ** linux-kernel -- all over the place... At that point, I was getting too many to keep up with ... so I stopped searching... $[] has is -- I would bet, Universally, used MORE than $(())... I believe you'd lose, but it's unprovable e

Re: status on $[arith] for eval arith vsl $((arith))??

2012-04-10 Thread Chet Ramey
On 4/10/12 12:22 AM, Elliott Forney wrote: > My two cents, would be to add a bit to the man page that says something like: > > --- > For historical reasons, the following format is also supported for > arithmetic evaluation: > > $[expression] > > Note, however, that this format is non-standa

Re: status on $[arith] for eval arith vsl $((arith))??

2012-04-10 Thread Chet Ramey
On 4/10/12 3:33 AM, Maarten Billemont wrote: > If we were to move to $[ ... ] But we're not. It's ludicrous to think we would. How far down the rabbit hole are we going to go on this? -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' -

  1   2   >