Re: hash not restored after running command -p

2021-10-31 Thread Oğuz
On Sun, Oct 31, 2021 at 10:26 PM Mike Jonkmans wrote: > POSIX is also silent on this. I think ``Once a utility has been searched for and found [...], an implementation may remember its location and need not search for the utility again unless the PATH variable has been the subject of an assignmen

Newlines in ERR trap affect caller 0 line number

2021-10-31 Thread Quinn Grier
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-musl Compiler: gcc Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security uname output: Linux e4cb51356521 5.11.0-38-generic #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021 x86_64 Linux Mac

Re: hash not restored after running command -p

2021-10-31 Thread Mike Jonkmans
On Sun, Oct 31, 2021 at 08:36:49PM +0300, Oğuz wrote: > On Sun, Oct 31, 2021 at 7:07 PM Mike Jonkmans wrote: > > > > On Sun, Oct 31, 2021 at 05:23:03PM +0200, Oğuz wrote: > > > 31 Ekim 2021 Pazar tarihinde Mike Jonkmans yazdı: > > > > > > > > Using the hash as alias for commands, that are not in

Re: hash not restored after running command -p

2021-10-31 Thread Oğuz
On Sun, Oct 31, 2021 at 7:07 PM Mike Jonkmans wrote: > > On Sun, Oct 31, 2021 at 05:23:03PM +0200, Oğuz wrote: > > 31 Ekim 2021 Pazar tarihinde Mike Jonkmans yazdı: > > > > > > Using the hash as alias for commands, that are not in your PATH, > > > seems risky though. > > > > Why? Risky how? > > R

Re: hash not restored after running command -p

2021-10-31 Thread Mike Jonkmans
On Sun, Oct 31, 2021 at 05:23:03PM +0200, Oğuz wrote: > 31 Ekim 2021 Pazar tarihinde Mike Jonkmans yazdı: > > > > Using the hash as alias for commands, that are not in your PATH, > > seems risky though. > > Why? Risky how? Risky, mostly on a cognitive level. 'command -p foo' doesn't look like i

Re: hash not restored after running command -p

2021-10-31 Thread Roger Morris
Thanks for the reply. Though POSIX may allow this, still the last line of the following example is rather unexpected behavior $ $ echo echo MY LOCAL tmp/date SCRIPT > tmp/date $ chmod +x tmp/date $ $ PATH=.:/bin $ date Sun 31 Oct 2021 11:59:07 AM EDT $ hash -l builtin hash -p /bin/date date $ cd

Re: hash not restored after running command -p

2021-10-31 Thread Oğuz
31 Ekim 2021 Pazar tarihinde Mike Jonkmans yazdı: > > Using the hash as alias for commands, that are not in your PATH, > seems risky though. Why? Risky how? -- Oğuz

Re: hash not restored after running command -p

2021-10-31 Thread Mike Jonkmans
On Sun, Oct 31, 2021 at 03:33:07PM +0300, Oğuz wrote: > On Sun, Oct 31, 2021 at 2:15 PM Mike Jonkmans wrote: > > PATH=/dev/null > > command -p hostname > > hostname # executes /bin/hostname via the hash table > > > > I agree with OP that the behaviour is a bug, or at least

Re: Arbitrary command execution from test on a quoted string

2021-10-31 Thread Greg Wooledge
On Sun, Oct 31, 2021 at 09:05:22AM +0100, felix wrote: > Unfortunely, this won't be useable with associative array, like: > >declare -A AssocVar='([Some string.]=foo)' >test -v AssocVar['Some string.'] && echo yes || echo no >yes >isvar AssocVar['Some string.'] && echo yes || echo

Re: hash not restored after running command -p

2021-10-31 Thread Oğuz
On Sun, Oct 31, 2021 at 2:15 PM Mike Jonkmans wrote: > PATH=/dev/null > command -p hostname > hostname # executes /bin/hostname via the hash table > > I agree with OP that the behaviour is a bug, or at least unwanted behaviour. I'd say it's a feature, and a good one too. N

Re: hash not restored after running command -p

2021-10-31 Thread Mike Jonkmans
On Sat, Oct 30, 2021 at 01:53:55PM -0400, Chet Ramey wrote: > On 10/29/21 6:06 PM, Roger Morris wrote: > > > Bash Version: 5.0 > > Patch Level: 17 > > Release Status: release > > > > Description: > > I believe there's a bug in bash 4.4 (and still in 5.1) that wasn't > > there in 4.3.30 > > > > W

Re: Arbitrary command execution from test on a quoted string

2021-10-31 Thread felix
Unfortunely, this won't be useable with associative array, like: declare -A AssocVar='([Some string.]=foo)' test -v AssocVar['Some string.'] && echo yes || echo no yes isvar AssocVar['Some string.'] && echo yes || echo no no But Lea's solution seem work: test "${AssocVar['Some