Page MenuHomePhabricator

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

Authored by abosh on Jun 27 2022, 12:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 11:10 PM
Unknown Object (File)
Sun, Nov 3, 7:45 PM
Unknown Object (File)
Sun, Nov 3, 7:45 PM
Unknown Object (File)
Sun, Nov 3, 7:41 PM
Unknown Object (File)
Sun, Nov 3, 7:24 PM
Unknown Object (File)
Oct 15 2024, 1:11 AM
Unknown Object (File)
Oct 7 2024, 4:42 AM
Unknown Object (File)
Oct 7 2024, 4:42 AM
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
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

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

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

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.)