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

SC2142: Function in the alias definition #1960

Open
2 tasks done
aeiplatform opened this issue May 21, 2020 · 1 comment
Open
2 tasks done

SC2142: Function in the alias definition #1960

aeiplatform opened this issue May 21, 2020 · 1 comment

Comments

@aeiplatform
Copy link

aeiplatform commented May 21, 2020

For bugs

  • Rule Id: SC2142
  • My shellcheck version: 0.7.0
  • The rule's wiki page does not already cover this at Wiki
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit

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

#!/bin/sh
alias idc='idc() { echo "$@"; }; idc'
alias idk='i() { echo "$@"; }; i'

Here's what shellcheck currently says:

Line 2:
alias idc='idc() { echo "$@"; }; idc'
      ^-- SC2142: Aliases can't use positional parameters. Use a function.
 
Line 3:
alias idk='i() { echo "$@"; }; i'
      ^-- SC2142: Aliases can't use positional parameters. Use a function.

Here's what I wanted or expected to see:

Nothing. Function is used in the alias definition.

@sparr
Copy link

sparr commented Jul 1, 2023

You can demonstrate this with a shorter anonymous function:

alias idc='() { echo "$@"; }'

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