Skip to content

Use sh safe commands - #89

Merged
glin merged 2 commits into
rstudio:masterfrom
schloerke:chrome_sh
Jul 19, 2021
Merged

glin merged 2 commits into
rstudio:masterfrom
schloerke:chrome_sh

Conversation

@schloerke

Copy link
Copy Markdown
Contributor

I tried to install chromote, and thought it'd work. It did not work with pak.

pak uses sh -c COMMAND which did not like the if/then/else/fi.

Ex: https://github.com/rstudio/chromote/pull/58/checks?check_run_id=3089030517#step:7:13

ℹ Executing `sudo apt-get install -y gnupg wget`
ℹ Executing `sudo if [ -z $(which google-chrome) ]; then wget -O /tmp/google-chrome.deb dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb; fi`

Error: Error: <callr_remote_error: System command 'sh' failed, exit status: 2, stdout + stderr:

I've tested locally using sh -c COMMAND and could reprex the problem. The updated commands below, should work better with sh -c COMMAND.


Within bash... The example below is an inline environment variable with a shorthand if-statement...

sh -c 'BARRET=schloerke; [ $(which google-chrome) ] || echo "$BARRET" '
# schloerke

Additional change:

  • No need to try to install gnupg and wget if no other installation will attempt to install.

@glin glin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with one small issue (from the CI failure). More portable commands are always great.

Comment thread rules/chrome.json Resolved
@glin
glin merged commit 96479e5 into rstudio:master Jul 19, 2021
@schloerke
schloerke deleted the chrome_sh branch July 19, 2021 17:44
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