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

Consider not to suggest quoting HOME, UID, etc. #2706

Open
2 tasks done
forthrin opened this issue Mar 2, 2023 · 5 comments
Open
2 tasks done

Consider not to suggest quoting HOME, UID, etc. #2706

forthrin opened this issue Mar 2, 2023 · 5 comments

Comments

@forthrin
Copy link

forthrin commented Mar 2, 2023

For bugs

Here's a snippet or screenshot that shows the problem:

#!/bin/bash
touch /var/mail/$USER

Here's what shellcheck currently says:

SC2086 Double quote to prevent globbing and word splitting.

Here's what I wanted or expected to see:

Should this check be lenient on standard environment variables that won't have problematic characters in any sane environment? (HOME UID LOGNAME RANDOM COLUMNS LINES, etc.). touch /var/mail/"$USER" seems a bit redundant.

@brother
Copy link
Collaborator

brother commented Mar 3, 2023

$ echo $HOME
/home/brother
$ mkdir "/tmp/apa gnu"
$ unset HOME
$ export HOME=/tmp/apa\ gnu/
$ echo $HOME 
/tmp/apa gnu/
$ cd $HOME
bash: cd: too many arguments
$ pwd
/home/brother
$ cd "$HOME"
$ pwd
/tmp/apa gnu

@forthrin
Copy link
Author

forthrin commented Mar 3, 2023

Which is exactly why I wrote "sane environment".

@brother
Copy link
Collaborator

brother commented Mar 3, 2023

And the point is that you can not dictate what that is.

@forthrin
Copy link
Author

forthrin commented Mar 3, 2023

Typiskt svenskt

@Atrate
Copy link

Atrate commented Mar 5, 2023

If anything, it will get you into the good habit of always quoting variables, and in this case it has no downside.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants