Page MenuHomePhabricator

[keyserver] Revise `dc.sh` passed parameters
ClosedPublic

Authored by abosh on Jun 27 2022, 12:07 PM.
Tags
None
Referenced Files
F2148633: D4367.diff
Sun, Jun 30, 5:46 AM
Unknown Object (File)
Sat, Jun 15, 1:59 PM
Unknown Object (File)
Fri, Jun 14, 7:53 PM
Unknown Object (File)
Thu, Jun 13, 7:54 PM
Unknown Object (File)
May 27 2024, 3:44 AM
Unknown Object (File)
May 27 2024, 3:44 AM
Unknown Object (File)
May 27 2024, 1:49 AM
Unknown Object (File)
May 14 2024, 1:46 PM
Subscribers

Details

Summary

Relevant Linear issue with full context here.

This diff cleans up dc.sh by revising the passed parameters to docker compose. They should be double quoted to properly expand the argument list. Additionally, the @ parameter can be used singularly without curly braces (see inline comment).

This script was initially introduced a few weeks ago in D4213, adding those reviewers here.

Test Plan

ShellCheck, close reading.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

abosh edited the summary of this revision. (Show Details)
abosh added a reviewer: tomek.
keyserver/bash/dc.sh
8 ↗(On Diff #13852)

The double quotes were added to avoid re-splitting elements.

The curly braces and the 1 were removed because "$@" has the same behavior as ${@:1}.

Source: Bash parameters and parameter expansions from IBM Developer Tutorials.

image.png (166×1 px, 54 KB)

Read more on this StackOverflow answer, from the same StackOverflow post @ashoat shared in D4213 here.

keyserver/bash/dc.sh
8 ↗(On Diff #13852)

Edit: The curly braces and the 1 were removed because "$@" has the same behavior as "${@:1}" (forgot the double quotes around ${@:1})

image.png (166×1 px, 46 KB)

If the file in the inline comment cannot be seen.

ashoat requested changes to this revision.Jun 28 2022, 9:33 AM

Back to you with a small question – does this still work with something like bash/dc.sh up --build? Wondering if the double quotes will mess that up

This revision now requires changes to proceed.Jun 28 2022, 9:33 AM

No, it shouldn't. I'm not sure why double quotes would mess it up, was there a reason you thought it could?

To be sure, I quickly wrote this script to compare outputs and parsing:

image.png (966×1 px, 253 KB)

The double quotes/simpler passed parameter syntax produces identical identical output for up --build:

image.png (1×1 px, 253 KB)

Can you test bash/dc.sh up --build and make sure it works?

No, it shouldn't. I'm not sure why double quotes would mess it up, was there a reason you thought it could?

Naive interpretation

Can you test bash/dc.sh up --build and make sure it works?

Just tested it. It works (the server runs and no errors).

This revision is now accepted and ready to land.Jun 30 2022, 8:55 AM

(By the way, you should hit "Re-request review" in these scenarios to pass the diff back to my queue after responding to the question.)