shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

tab character support

Open FinzelStefan opened this issue 5 years ago • 4 comments

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.

FinzelStefan avatar Aug 01 '19 17:08 FinzelStefan

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       .

Gandalf- avatar Aug 07 '19 04:08 Gandalf-

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 :)

Bearwolves avatar Sep 16 '20 13:09 Bearwolves

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.

dfarrell07 avatar May 19 '22 13:05 dfarrell07

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

dfarrell07 avatar Jun 02 '22 14:06 dfarrell07

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.

mxcl avatar Oct 21 '22 14:10 mxcl