Skip to content

style(bash): use consistent coding style#1528

Merged
ellie merged 6 commits intoatuinsh:mainfrom
akinomyoga:bash-style
Jan 9, 2024
Merged

style(bash): use consistent coding style#1528
ellie merged 6 commits intoatuinsh:mainfrom
akinomyoga:bash-style

Conversation

@akinomyoga
Copy link
Contributor

This is just a cosmetic one. I originally planned to submit this after settling all the planned PRs, but some would overlap. I still have two planned PRs, but I'd like to submit this before those two.

Different coding styles and indentations are mixed in the current atuin.bash. In this PR, I try to normalize them. I separate the commits for each topic. These are more or less preferences, so if you would like the normalization the other way around, please specify it. I can adjust them (after the confirmation about the consequences if needed).

As usual, I left descriptions in commit messages.

@vercel
Copy link

vercel bot commented Jan 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
atuin-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2024 0:12am

Initially, in this file, the first level is indented by four spaces,
and additional levels are indented by adding two spaces.  However,
this does not seem intentional because the other files, such as
atuin.zsh, are consistently indented by four spaces for any levels.
The indentation was gradually fixed to use four spaces when the
relevant code is updated, but there are still remaining parts using
two spaces.  In this patch, the remaining parts are updated to use the
consistent indentation of four spaces.
On the right-hand sides of assignments, the quoting of the variable
expansions are not needed because they are not subject to the word
splitting and the pathname expansions.
In the conditional commands [[ ... ]], the words are not subject to
the word splitting and the pathname expansions, so we do not need to
quote the expansions except for the right-hand sides of ==, !=, and
=~, where the quoting has a special meaning.  In the first place, the
syntax [[ .. ]] is introduced to resolve the issue of the quoting, so
it is natural to use the unquoted form inside [[ ... ]] by default.
In this patch, we use the unquoted form of expansions.
This is also the format that Bash outputs with `bash --pretty-print
FILE` or `declare -f FUNC`.
Copy link
Member

@ellie ellie left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@ellie ellie enabled auto-merge (squash) January 9, 2024 20:42
@ellie ellie merged commit f63f246 into atuinsh:main Jan 9, 2024
@akinomyoga akinomyoga deleted the bash-style branch January 9, 2024 22:07
@akinomyoga
Copy link
Contributor Author

Thanks!

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