From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 74962@debbugs.gnu.org
Cc: "Maxim Cournoyer" <maxim.cournoyer@gmail.com>,
"Janneke Nieuwenhuizen" <janneke@gnu.org>,
"Josselin Poiret" <dev@jpoiret.xyz>,
"Ludovic Courtès" <ludo@gnu.org>,
"Mathieu Othacehe" <othacehe@gnu.org>
Subject: [bug#74962] [PATCH 3/3] etc/guix-install.sh: Fix quoting and other issues.
Date: Thu, 19 Dec 2024 16:17:52 +0900 [thread overview]
Message-ID: <6b04713cc24b58ab4bbf4ac4060e4d57f7c8e1b3.1734592672.git.maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <f7f432d7d1672c8934a4a3f50db4b858f1261f66.1734592672.git.maxim.cournoyer@gmail.com>
This change fixes most issues reported by the 'shellcheck' command.
* etc/guix-install.sh (add_init_sys_require): Use -n instead of ! -z.
(sys_create_build_user): Quote variable expansion.
(sys_delete_build_user): Likewise.
(sys_create_shell_completion): Likewise.
(sys_delete_user_profiles): Likewise.
(main): Replace $@ with $* inside string.
Change-Id: Ia88509b461b3844f2dd5abf9fb21a5b2bbb8a1e1
---
etc/guix-install.sh | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 481eb6f12a..2ab443d97b 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -151,7 +151,7 @@ chk_require()
add_init_sys_require()
{ # Add the elements of FOO_INIT_SYS to REQUIRE
local init_require="${INIT_SYS}_REQUIRE[@]"
- if [[ ! -z "$init_require" ]]; then
+ if [[ -n "$init_require" ]]; then
# Have to add piecemeal because ${!foo[@]} performs direct array key
# expansion, not indirect plain array expansion.
for r in "${!init_require}"; do
@@ -427,12 +427,12 @@ sys_create_build_user()
for i in $(seq -w 1 10); do
if id "guixbuilder${i}" &>/dev/null; then
_msg "${INF}user is already in the system, reset"
- usermod -g guixbuild -G guixbuild${KVMGROUP} \
+ usermod -g guixbuild -G "guixbuild${KVMGROUP}" \
-d /var/empty -s "$(which nologin)" \
-c "Guix build user $i" \
"guixbuilder${i}";
else
- useradd -g guixbuild -G guixbuild${KVMGROUP} \
+ useradd -g guixbuild -G "guixbuild${KVMGROUP}" \
-d /var/empty -s "$(which nologin)" \
-c "Guix build user $i" --system \
"guixbuilder${i}";
@@ -445,7 +445,7 @@ sys_delete_build_user()
{
for i in $(seq -w 1 10); do
if id -u "guixbuilder${i}" &>/dev/null; then
- userdel -f guixbuilder${i}
+ userdel -f "guixbuilder${i}"
fi
done
@@ -681,7 +681,7 @@ sys_create_shell_completion()
{ # Just in case
for dir_shell in $bash_completion $zsh_completion $fish_completion; do
- [ -d "$dir_shell" ] || mkdir -p $dir_shell
+ [ -d "$dir_shell" ] || mkdir -p "$dir_shell"
done;
ln -sf ${var_guix}/etc/bash_completion.d/* "$bash_completion";
@@ -747,10 +747,10 @@ sys_delete_user_profiles()
rm -rf ~root/.cache/guix
_msg "${INF}removing .guix-profile, .cache/guix and .config/guix of all /home users"
- for user in `ls -1 /home`; do
- rm -f /home/$user/.guix-profile
- rm -rf /home/$user/.cache/guix
- rm -rf /home/$user/.config/guix
+ for user in /home/*; do
+ rm -f "/home/$user/.guix-profile"
+ rm -rf "/home/$user/.cache/guix"
+ rm -rf "/home/$user/.config/guix"
done
}
@@ -898,7 +898,7 @@ main()
if [ '--uninstall' = "${uninstall_flag}" ]; then
main_uninstall
else
- echo "unsupported parameters: $@"
+ echo "unsupported parameters: $*"
exit 1
fi
fi
--
2.46.0
next prev parent reply other threads:[~2024-12-19 7:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 6:57 [bug#74962] [PATCH] etc/guix-install.sh: Explicit shebang to use /usr/bin/env Maxim Cournoyer
2024-12-19 7:17 ` [bug#74962] [PATCH 1/3] etc/teams.scm: Add etc/guix-install.sh to installer team scope Maxim Cournoyer
2024-12-19 7:17 ` [bug#74962] [PATCH 2/3] etc/guix-install.sh: Explicit shebang to use /usr/bin/env Maxim Cournoyer
2024-12-19 8:18 ` Janneke Nieuwenhuizen
2024-12-19 12:48 ` Maxim Cournoyer
2024-12-19 7:17 ` Maxim Cournoyer [this message]
2024-12-19 7:45 ` [bug#74962] [PATCH v3 1/5] etc/teams.scm: Add etc/guix-install.sh to installer team scope Maxim Cournoyer
2024-12-19 7:45 ` [bug#74962] [PATCH v3 2/5] etc/guix-install.sh: Explicit shebang to use /usr/bin/env Maxim Cournoyer
2024-12-19 7:45 ` [bug#74962] [PATCH v3 3/5] etc/guix-install.sh: Fix quoting and other issues Maxim Cournoyer
2024-12-19 7:45 ` [bug#74962] [PATCH v3 4/5] etc/guix-install.sh: Remove 'which' commands from requirements Maxim Cournoyer
2024-12-19 7:45 ` [bug#74962] [PATCH v3 5/5] etc/guix-install.sh: Sort requirements Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6b04713cc24b58ab4bbf4ac4060e4d57f7c8e1b3.1734592672.git.maxim.cournoyer@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=74962@debbugs.gnu.org \
--cc=dev@jpoiret.xyz \
--cc=janneke@gnu.org \
--cc=ludo@gnu.org \
--cc=othacehe@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).