-
Notifications
You must be signed in to change notification settings - Fork 873
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
dev.sh fixups #2114
dev.sh fixups #2114
Conversation
Instead of switching between windows and non-windows to determine how to handle slashes for msbuild, use dashes instead of slashes to simplify the calling.
Stop on errors, instead of continuing. This prevents us from failing to move through the directory space with `cd` / `pushd` / `popd` but still running commands. This is particularly dangerous when running commands like `rm`.
Since directories may have a space in them, quote them to treat them as a single entity instead of wordsplitting on a space. Otherwise, if `FOO="a b c"` then `rm -rf $FOO` will remove files or folders named `a`, b`, and `c` instead of removing the single entity named `a b c`.
When expanding variables to pass to `rm`, make sure that the path variable is set and fail if it is not. This prevents an `rm` from accidentally expanding to `rm ""/*` when the variable is unset: ValveSoftware/steam-for-linux#3671 Using `${FOO:?}` syntax will fail when `FOO` is unset.
`$LastExitCode` is not a bash variable; to pass that string along to PowerShell, it needs to be quoted.
The $(cmd) execution syntax is preferred over the legacy backtick syntax.
Quote the variables for the directories so that we can properly work with directories with spaces in their names.
@ethomson Thanks! 🥇 |
Awesome, thanks @TingluoHuang! 😀 |
find "${LAYOUT_DIR}/bin" -type f -name '*.pdb' -delete | ||
|
||
mkdir -p "$PACKAGE_DIR" | ||
rm -Rf "${PACKAGE_DIR:?}/*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The * here got caught in the quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 good catch, you want to create a PR? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the encouragement, but I'm afraid I care only enough to drop a drive-by comment. You can decide if it's actually worth fixing. :)
I cloned the
azure-pipelines-agent
to a directory name with a space in it and after doing so,dev.sh
commands did not work; the bulk of these commits deal with that issue.In particular, this starts quoting all variable strings to ensure that they're not wordsplit on spaces. Otherwise:
will remove both
/home/ethomson/foo
andbar asdf
. Quoting asrm -rf "$DIRECTORY"
will treat the entire path (with a space in it) as a single string, as expected.This also adds some safety around
rm
s to avoid accidentally coping with empty strings, similar to the problem that happened in ValveSoftware/steam-for-linux#3671. Otherwise, acd
into a directory followed by anrm
becomes dangerous if thecd
failed.As a result, this enables
set -e
to avoid continuing when acd
orpushd
(or any command) fails. (As would happen with an unquoted space in the path, or to a directory that doesn't exist.)Similarly, using
${FOO:?}/*
will ensure that ifFOO
is unset that the command fails instead of trying torm /*
.After that I just ran shellcheck against the scripts and fixed up the remainder of warnings.