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

Use POSIX strict mode #304

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Use POSIX strict mode #304

wants to merge 2 commits into from

Conversation

RichiH
Copy link
Owner

@RichiH RichiH commented Jun 23, 2021

Closes #303.

Fixes #303

Signed-off-by: Richard Hartmann <[email protected]>
@RichiH RichiH marked this pull request as draft June 23, 2021 08:56
@RichiH
Copy link
Owner Author

RichiH commented Jun 23, 2021

I am unsure if

vcsh/vcsh.in

Line 704 in 4f013c3

if echo "$VCSH_REPO_NAME" | @GREP@ -q '/'; then
should simply be ${VCSH_REPO_NAME-} or if that's overly brittle given what we're trying to achieve with strict mode. We might want to add a variable which explicitly tells us if VCSH_REPO_NAME should be set instead of transporting this information implicitly by the variable itself being set, or not. I am not certain if that's more resilient in the end, though.

@alerque alerque added this to the v2.0.0 milestone Jun 23, 2021
`set -o nounset` made it clear that my flow control is really really bad
and relies heavily on $VCSH_REPO_NAME transporting information both
through its value and by being set or not. That will need to be cleaned
up.

NB: It might be an option to set it to empty as a global and leave it as
that, but that seems icky and brittle.

Signed-off-by: Richard Hartmann <[email protected]>
@@ -735,11 +742,13 @@ VCSH_COMMAND=$(echo "$VCSH_COMMAND" | @SED@ 's/-/_/g'); export VCSH_COMMAND

# Source repo-specific configuration file
# shellcheck source=/dev/null
[ -r "$XDG_CONFIG_HOME/vcsh/config.d/$VCSH_REPO_NAME" ] \
# TODO: And we rely on $VCSH_REPO_NAME implictly again
[ -r "$XDG_CONFIG_HOME/vcsh/config.d/${VCSH_REPO_NAME-}" ] \
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will only suceed by a somewhat odd side effect, -r tests specifically for files not directories so it will fail if the values is unset and the path is only to the directory. While the result is correct, the code logic is pretty opaque.

As the assorted comments here note, the active repo(s) name handling should probably be overhauled entirely.

@alerque alerque removed this from the v2.0.0 milestone Jul 14, 2021
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.

POSIX strict mode
2 participants