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

Fix ShellCheck warnings and errors #431

Merged
merged 1 commit into from
Sep 23, 2022
Merged

Fix ShellCheck warnings and errors #431

merged 1 commit into from
Sep 23, 2022

Conversation

fpoli
Copy link
Member

@fpoli fpoli commented Sep 22, 2022

Fix warnings and errors reported by ShellCheck:

> shellcheck carbon.sh 

In carbon.sh line 23:
BASEDIR="$(realpath `dirname $0`)"
                    ^----------^ SC2046 (warning): Quote this to prevent word splitting.
                    ^----------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
                             ^-- SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
BASEDIR="$(realpath $(dirname "$0"))"


In carbon.sh line 27:
if [ ! -f $CP_FILE ]; then
          ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if [ ! -f "$CP_FILE" ]; then


In carbon.sh line 28:
    (cd $BASEDIR; sbt "export runtime:dependencyClasspath" | tail -n1 > $CP_FILE)
        ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                        ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    (cd "$BASEDIR"; sbt "export runtime:dependencyClasspath" | tail -n1 > "$CP_FILE")


In carbon.sh line 31:
java -Xss30M -cp "`cat $CP_FILE`" viper.carbon.Carbon $@
                  ^------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
                       ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                      ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.

Did you mean: 
java -Xss30M -cp "$(cat "$CP_FILE")" viper.carbon.Carbon $@

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
  https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...
  https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...

@fpoli
Copy link
Member Author

fpoli commented Sep 23, 2022

With this PR on Ubuntu 22.04 I can pass filenames containing spaces to Carbon. Before it was incorrectly complaining about extra arguments.

Note that the carbon.bat might benefit from similar fixes done to silicon.bat. See viperproject/silicon#588.

@gauravpartha
Copy link
Contributor

Looks good to me, thanks!

@gauravpartha gauravpartha reopened this Sep 23, 2022
@gauravpartha gauravpartha merged commit 992710d into master Sep 23, 2022
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

Successfully merging this pull request may close these issues.

2 participants