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

SC2319 warns to assign $? to a var, IN an assignment to a var (0.10.0 broke, shellcheck.net not broken) #2952

Open
1 of 2 tasks
mobilemind opened this issue Mar 21, 2024 · 0 comments

Comments

@mobilemind
Copy link

For bugs

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

#!/usr/bin/env bash# COMMDIR - home dir for common utils
COMMDIR="${HOME}/Developer/common"
## read/write access to $PROJDIR is required
[ -d "${COMMDIR}" ] || die "warning: no directory found at- ${COMMDIR}" 0
[ -w "${COMMDIR}" ] \
	|| { ERR="$?" ; die "write access to ${COMMDIR} is required. Error: $ERR" "$ERR" ; }

Here's what shellcheck currently says:

In common/bin/commfresh.sh line 90:
|| { ERR="$?" ; die "write access to ${COMMDIR} is required. Error: $ERR" "$ERR" ; }
^-- SC2319 (warning): This $? refers to a condition, not a command. Assign to a variable to avoid it being overwritten.

Here's what I wanted or expected to see:

No warning using local executable, like I see no warning using shellcheck.net.

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

1 participant