Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh commands output by install.sh have syntax issues #3457

Open
rvernica opened this issue Nov 6, 2024 · 7 comments
Open

zsh commands output by install.sh have syntax issues #3457

rvernica opened this issue Nov 6, 2024 · 7 comments
Labels
needs followup We need some info or action from whoever filed this issue/PR. shell: zsh

Comments

@rvernica
Copy link

rvernica commented Nov 6, 2024

Operating system and version:

Linux 6.11.3-200.fc40.x86_64 # 1 SMP PREEMPT_DYNAMIC Thu Oct 10 22:31:19 UTC 2024 x86_64 GNU/Linux

nvm debug output:

> nvm debug
nvm --version: v0.40.1
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'vernica'
${HOME}: /home/vernica
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/local/bin:${HOME}/.local/bin:${HOME}/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.9 (x86_64-redhat-linux-gnu)'
uname -a: 'Linux 6.11.3-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Oct 10 22:31:19 UTC 2024 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Fedora Linux 40 (Workstation Edition)
awk: /usr/bin/awk, GNU Awk 5.3.0, API 4.0, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.2.1)
curl: /usr/bin/curl, curl 8.6.0 (x86_64-redhat-linux-gnu) libcurl/8.6.0 OpenSSL/3.2.2 zlib/1.3.1.zlib-ng brotli/1.1.0 libidn2/2.3.7 libpsl/0.21.5 libssh/0.10.6/openssl/zlib nghttp2/1.59.0 OpenLDAP/2.6.7
wget: /usr/bin/wget, GNU Wget2 2.1.0 - multithreaded metalink/file/website downloader
git: /usr/bin/git, git version 2.47.0
ls: cannot access 'grep='\''grep'$'\n''/usr/bin/grep': No such file or directory
grep: grep='grep --color=auto'
	/usr/bin/grep (grep --color=auto), grep (GNU grep) 3.11
sed: /usr/bin/sed, sed (GNU sed) 4.9
cut: /usr/bin/cut, cut (GNU coreutils) 9.4
basename: /usr/bin/basename, basename (GNU coreutils) 9.4
ls: cannot access 'rm='\''rm'$'\n''/usr/bin/rm': No such file or directory
rm: rm='rm -i'
	/usr/bin/rm (rm -i), rm (GNU coreutils) 9.4
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 9.4
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.9.0
nvm current: system
which node: /usr/bin/node
which iojs: iojs not found
which npm: /usr/bin/npm
npm config get prefix: /usr/local
npm root -g: /usr/local/lib/node_modules

nvm ls output:

> nvm ls

->       system
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)

How did you install nvm?

> curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

What steps did you perform?

> curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

What happened?

I copied and pasted the lines as the install script instructed and they show errors in ZSH:

> curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
...
=> Downloading nvm from git to '/home/vernica/.nvm'
=> Cloning into '/home/vernica/.nvm'...
...
=> Compressing and cleaning up git repository

=> Appending nvm source string to /home/vernica/.zshrc
=> Appending bash_completion source string to /home/vernica/.zshrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion


> export NVM_DIR="$HOME/.nvm" 
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

zsh: bad pattern: #

What did you expect to happen?

The commands output by the script should not have syntax errors.

Is there anything in any of your profile files that modifies the PATH?

> grep -i PATH ~/.zshrc
fpath=(~/local/completion $fpath)
## -- - PATH - --
path=("$HOME/local/bin" "$HOME/.local/bin" "$HOME/go/bin" $path)
export NODE_PATH=$HOME/usr/lib/node_modules
#         export PATH="/home/vernica/miniforge3/bin:$PATH"
@ljharb
Copy link
Member

ljharb commented Nov 6, 2024

While you certainly shouldn’t be setting NODE_PATH with or without nvm, that “bad pattern” error is concerning. Does it continue to occur, or only during the install script?

@rvernica
Copy link
Author

rvernica commented Nov 6, 2024

The bad pattern error is caused by the presence of # in the commands (used for comments). In Zsh scripts, it is fine, but in Zsh commands, it is bad.

For example:

> ls # foo
zsh: bad pattern: #

So, these commands get added to my ~/.zshrc script and work fine as # indicates a comment, but if I copy & paste the commands (as the install script suggests) that will trigger the bad pattern error.

@ljharb
Copy link
Member

ljharb commented Nov 6, 2024

ahhh thanks for clarifying.

It seems very strange that zsh would treat a line in a sourced script any differently from a line in the terminal directly; that seems like a huge bug farm. Is perhaps your shell non-interactive? Alternatively, have you altered the default behavior of the interactivecomments zsh option?

@ljharb ljharb added shell: zsh needs followup We need some info or action from whoever filed this issue/PR. labels Nov 6, 2024
@rvernica
Copy link
Author

rvernica commented Nov 6, 2024

It is an interactive Zsh prompt and I made no changes to the behavior of interactivecomments

@ljharb
Copy link
Member

ljharb commented Nov 7, 2024

what's setopt output?

@rvernica
Copy link
Author

rvernica commented Nov 7, 2024

> setopt
autocd
nobeep
extendedglob
interactive
monitor
promptsubst
shinstdin
zle

@ljharb
Copy link
Member

ljharb commented Nov 7, 2024

my stock zsh has:

combiningchars
interactive
monitor
shinstdin
zle

so you have autocd, nobeep, extendedglob, and promptsubst enabled, and combiningchars disabled. Could you try flipping each of those one at a time and seeing if it makes anything change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs followup We need some info or action from whoever filed this issue/PR. shell: zsh
Projects
None yet
Development

No branches or pull requests

2 participants