bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'hash foo' may fail, and would require something like 'hash /usr/bin


From: Benoit Lacelle
Subject: Re: 'hash foo' may fail, and would require something like 'hash /usr/bin/foo'
Date: Tue, 22 Feb 2022 17:48:56 +0100

Just in case, the reference github tickets holds additional details (
https://github.com/disney/meteor-base/pull/102#issuecomment-1047254127). I
was unsure what best to provide in this report.

By fail, I mean 'hash npm' unexpectedly returns 'bash: hash: npm: not
found' in given CircleCI environment, while in other environments (e.g.
local MacOS), it returns (as expected) an empty output (as in both
cases, 'npm' does succeeded resolving a path and execuring npm).

Here some additional details:

bash-5.1# if hash npm 2>/dev/null; then echo 'npm_ok'; else echo 'npm_ko'; fi
npm_ko
bash-5.1# hash
hash: hash table empty
bash-5.1# hash npm
bash: hash: npm: not found
bash-5.1# npm

Usage: npm <command>

...

npm@6.14.15 /usr/local/lib/node_modules/npm
bash-5.1# hash
hits    command
   1    /usr/local/bin/npm
bash-5.1# hash npm
bash: hash: npm: not found
bash-5.1# hash /usr/local/bin/npm
hash /usr/local/bin/npm


Le mar. 22 févr. 2022 à 17:44, Chet Ramey <chet.ramey@case.edu> a écrit :

> On 2/22/22 10:10 AM, Benoit Lacelle wrote:
>
> > Bash Version: 5.1
> > Patch Level: 16
> > Release Status: relase
> > Bash version: 5.1.16(1)-release (x86_64-alpine-linux-musl)
> >
> > Description:
> > Issue discussed at https://github.com/disney/meteor-base/pull/102
> > Supposedly related with Bash5.1, 'hash npm' now fails in very recent
> bash,
> > but not in local macos bash, nor older linux docker images bashes
>
> What does `fail' mean here? Does it give an error message? The only ways
> hash can fail are if it doesn't find the given name in $PATH or if the
> given name, while found in $PATH, is not an executable file.
>
>
> > Fix:
> > 1- Rely on sh instead of bash for given docker image
>
>
>
> > 2- Update our script from 'hash npm' to 'hash /usr/bin/npm'
>
> What is that expected to do? It certainly won't put `npm' into the hash
> table. You probably want `hash -p /usr/bin/npm npm' instead.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/
>


-- 
Benoit Lacelle
Java/ML/BigData Elite Engineer
+33 6 78 83 92 66
benoit.lacelle@solven.eu


reply via email to

[Prev in Thread] Current Thread [Next in Thread]