shellcheck
shellcheck copied to clipboard
tab character support
As shellcheck can even be used for style checks I ask for an tabulator check in the verbose mode.
Sometimes tabulator characters especially in echo may lead to confusing output.
-
a tabulator warning for strings in quotation marks would be fine.
-
a general tabulator warning is not required, but would much more simple to implement. But this may lead to massive warnings as some use tabulator to indent source code.
There doesn't seem to be a consensus on tab vs spaces use for shell scripts when used for indentation. I agree a general warning for tab usage doesn't seem like a good idea.
- https://unix.stackexchange.com/questions/39210/whats-the-standard-for-indentation-in-shell-scripts
- https://stackoverflow.com/questions/28832899/proper-indentation-of-bash-script
We could a general warning when a literal tab character is used in place of \t
in quoted strings like you suggest. Making this verbose mode only behavior might be confusing.
#!/bin/bash
x=".<literal tab>a\t."
echo "$x"
$ bash example.sh
. a .
It would be still nice to have the possibility to enable a check if tabs/enough spaces are used outside the echo or not i.e. in the "body" of our scripts. This check could be by default off. This is especially useful in big teams to automate the check to avoid style conflict in software version control system :)
I think there may be consensus that mixed tabs and spaces are not good. Agree that it would useful for enforcing consistent style in large projects.
We ended up adding a check like ! grep $$'\t'
to our shellcheck Make target to have this feature.
https://github.com/submariner-io/shipyard/pull/835/files#diff-45f338d2aca0e170b4531d9554b6a2a0ad301a651de3a0c237af4365dabbf2ffR199
to add my 2¢, I wanted a lint check for tab characters, not spaces since the heredoc syntax of <<-HEREDOC
requires tabs and fails with spaces.