[bug#33134,2/5] guix-install.sh: Add parse_args.

Message ID 20181103011048.73864-1-s@ricketyspace.net
State New
Headers show
Series
  • Add auto yes/no switch to guix-install.sh
Related show

Checks

Context Check Description
cbaines/applying patch success Successfully applied

Commit Message

rsiddharth Nov. 3, 2018, 1:10 a.m. UTC
* etc/guix-install.sh (parse_args): New function.
---
 etc/guix-install.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Danny Milosavljevic Nov. 6, 2018, 11:27 a.m. UTC | #1
Hi,

> +    # process -y / -n arg.
> +    export AUTO_YN=${1:1:1}
> +    if [ -z $AUTO_YN ]; then
> +        export AUTO_YN=""
> +    fi

Why "export" ? Now all the child processes get it, making their environment
different from before.  This makes parse_args have system-wide side effects.

If we wanted to export it, we could do it explicitly after parse_args has
been called.

Patch

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index cf839c20e..d16f8ac59 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -370,6 +370,21 @@  sys_authorize_build_farms()
     done
 }
 
+parse_args()
+{
+    local args_num=$#
+
+    if [ $args_num -lt 1 ]; then
+        return
+    fi
+
+    # process -y / -n arg.
+    export AUTO_YN=${1:1:1}
+    if [ -z $AUTO_YN ]; then
+        export AUTO_YN=""
+    fi
+}
+
 welcome()
 {
     cat<<"EOF"