darxkies / k8s-tew

Kubernetes - The Easier Way
GNU General Public License v3.0
307 stars 38 forks source link

exporting PATH as part of k8s-tew environment needs double quotes #32

Closed flamechair closed 3 years ago

flamechair commented 4 years ago

Hi,

I ran eval $(k8s-tew environment) and it would set some variables but not all in my environment. anything after exporting PATH would not make it, I dug into it and its because of a syntax error related to the existing PATH:

bash: test.sh: line 22445: syntax error near unexpected token `('
bash: test.sh: line 22445: `export PATH=/home/tyler/assets/opt/k8s-tew/bin:/home/tyler/assets/opt/k8s-tew/bin/k8s:/home/tyler/assets/opt/k8s-tew/bin/etcd:/home/tyler/assets/opt/k8s-tew/bin/cri:/home/tyler/assets/opt/k8s-tew/bin/cni:/home/tyler/assets/opt/k8s-tew/bin/velero:/home/tyler/assets/opt/k8s-tew/bin/host:/home/tyler/bin:/home/tyler/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/python/scripts/:/mnt/c/python/:/mnt/c/program files (x86)/common files/oracle/java/javapath:/mnt/c/windows/system32:/mnt/c/windows:/mnt/c/windows/system32/wbem:/mnt/c/windows/system32/windowspowershell/v1.0/:/mnt/c/windows/system32/openssh/:/mnt/c/program files/calibre2/:/mnt/c/program files/microsoft vs code/bin:/mnt/c/users/tyler/appdata/roaming/cloud foundry:/mnt/c/Program Files/FileBot/:/mnt/c/Users/tyler/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files (x86)/Nmap:/snap/bin:/usr/local/go/bin:/home/tyler/projects/go/bin'

The export chokes on the ( character because the export isn't wrapped in double quotes, if you wrap it in double quotes like so:

export PATH="/home/tyler/assets/opt/k8s-tew/bin:/home/tyler/assets/opt/k8s-tew/bin/k8s:/home/tyler/assets/opt/k8s-tew/bin/etcd:/home/tyler/assets/opt/k8s-tew/bin/cri:/home/tyler/assets/opt/k8s-tew/bin/cni:/home/tyler/assets/opt/k8s-tew/bin/velero:/home/tyler/assets/opt/k8s-tew/bin/host:/home/tyler/bin:/home/tyler/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/python/scripts/:/mnt/c/python/:/mnt/c/program files (x86)/common files/oracle/java/javapath:/mnt/c/windows/system32:/mnt/c/windows:/mnt/c/windows/system32/wbem:/mnt/c/windows/system32/windowspowershell/v1.0/:/mnt/c/windows/system32/openssh/:/mnt/c/program files/calibre2/:/mnt/c/program files/microsoft vs code/bin:/mnt/c/users/tyler/appdata/roaming/cloud foundry:/mnt/c/Program Files/FileBot/:/mnt/c/Users/tyler/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files (x86)/Nmap:/snap/bin:/usr/local/go/bin:/home/tyler/projects/go/bin"

Without double quoting PATH:

tyler@TYLER-DESKTOP:~$ eval $(k8s-tew environment)
tyler@TYLER-DESKTOP:~$ echo $KUBECONFIG

tyler@TYLER-DESKTOP:~$ k8s-tew environment > test.sh
tyler@TYLER-DESKTOP:~$ . test.sh
bash: test.sh: line 22445: syntax error near unexpected token `('
bash: test.sh: line 22445: `export PATH=/home/tyler/assets/opt/k8s-tew/bin:/home/tyler/assets/opt/k8s-tew/bin/k8s:/home/tyler/assets/opt/k8s-tew/bin/etcd:/home/tyler/assets/opt/k8s-tew/bin/cri:/home/tyler/assets/opt/k8s-tew/bin/cni:/home/tyler/assets/opt/k8s-tew/bin/velero:/home/tyler/assets/opt/k8s-tew/bin/host:/home/tyler/bin:/home/tyler/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/python/scripts/:/mnt/c/python/:/mnt/c/program files (x86)/common files/oracle/java/javapath:/mnt/c/windows/system32:/mnt/c/windows:/mnt/c/windows/system32/wbem:/mnt/c/windows/system32/windowspowershell/v1.0/:/mnt/c/windows/system32/openssh/:/mnt/c/program files/calibre2/:/mnt/c/program files/microsoft vs code/bin:/mnt/c/users/tyler/appdata/roaming/cloud foundry:/mnt/c/Program Files/FileBot/:/mnt/c/Users/tyler/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files (x86)/Nmap:/snap/bin:/usr/local/go/bin:/home/tyler/projects/go/bin'

With double quoting PATH:

tyler@TYLER-DESKTOP:~$ nano test.sh
tyler@TYLER-DESKTOP:~$ . test.sh
tyler@TYLER-DESKTOP:~$ echo $KUBECONFIG
/home/tyler/assets/etc/k8s-tew/k8s/kubeconfig/admin.kubeconfig

This is most likely due to me running the command on WSL (thus the Program Files (x86)), but it would also prevent it from happening to any other users that happen to have parenthesis in their PATH

Using k8s-tew version 2.4.0-beta.5, running Ubuntu 20.04.1 LTS on nodes

darxkies commented 4 years ago

I think I got it. I'll take a look at it.

darxkies commented 3 years ago

Fixed in master.