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

SC1001 should at least acknowledge alias suppression as the potential intent of a backslash-quoted initial command-name letter #927

Closed
1 task done
mklement0 opened this issue Jun 6, 2017 · 1 comment

Comments

@mklement0
Copy link

For bugs

  • SC1001
  • online
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit

I know that there are preexisting, closed issues (#552, #485, #188), but I think the issue is worth revisiting.

Unlike what the wiki entry states:

  • \foo for alias suppression is POSIX-compliant (as are 'foo' and "foo"), from what I can tell (see below). dash, probably the strictest implementation of the POSIX shell spec, accepts it.

    • Note that even though alias expansion in scripts (non-interactive shells) is disabled by default, the mechanism is still needed on occasion, such as when writing functions that are sourced for interactive use.
  • command foo is not a substitute for \foo, because, unlike \foo, it also bypasses shell functions - see the command POSIX spec.


As for why \foo to suppress alias expansion of foo is POSIX-compliant:

2.3.1 Alias Substitution states (emphasis added):

After a token has been delimited, but before applying the grammatical rules in Shell Grammar, a resulting word that is identified to be the command name word of a simple command shall be examined to determine whether it is an unquoted, valid alias name.

Note that quote removal has NOT yet happened at this stage, so, if the alias name is foo, \foo is clearly not the same.

koalaman added a commit that referenced this issue Jul 3, 2017
@koalaman
Copy link
Owner

koalaman commented Jul 3, 2017

This long standing annoyance has now been fixed. Any leading \ for a command will now be ignored.

@koalaman koalaman closed this as completed Jul 3, 2017
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

2 participants