G2-Games / welcome.sh

A nice welcome script for Bash and Zsh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

clock:17: ampm: parameter not set

tripplehelix opened this issue · comments

Just getting this error since 1.1.0 update. with twelvehour="off"

image

Also when using the random greetings:

greetings=("Welcome" "Greetings" "Hello" "Hi")
randgreeting="on"

I get the error:

welcome:14: greetings[$greetingsNumber]: parameter not set

Shell: Zsh Kernel: 6.1.0-5-amd64 arch: x86_64 Distro: Debian GNU/Linux 12 (bookworm)

commented

Thanks, I'll look into it as soon as possible.

commented

The latest version should fix this, thanks for alerting me!

image

I am now getting this sometimes when running welcome.sh however it no longer prints an error.

commented

Could you provide the output of bash -x ~/.welcome/welcome.sh? Or replace Bash with Zsh if you use that

+ export LC_NUMERIC=en_US.UTF-8
++ ps -o args= -p 71143
++ grep -Em 1 -o '\w{0,5}sh'
++ head -1
+ environment=bash
+ version=1.1.1
+ NCOL='\e[0m'
+ BOLD='\e[1m'
+ ITAL='\e[3m'
+ UNDR='\e[4m'
+ BLNK='\e[5m'
+ CRIT='\e[31m'
+ LOW='\e[33m'
+ NORM='\e[32m'
+ FULL='\e[3;4;92m'
+ TIME='\e[38;2;224;146;252;1m'
+ DATE='\e[38;2;50;168;82;1m'
++ randcolor
++ cluma=0
++ loops=0
+++ printf %.0f 0
++ '[' 0 -le 100 ']'
++ '[' 0 -le 10 ']'
++ cr=61
+++ echo '61 0.299'
+++ awk '{print $1 * $2}'
++ crl=18.239
++ cg=177
+++ echo '177 0.587'
+++ awk '{print $1 * $2}'
++ cgl=103.899
++ cb=30
+++ echo '30 0.114'
+++ awk '{print $1 * $2}'
++ cbl=3.42
+++ echo '18.239 103.899 3.42'
+++ awk '{print $1 + $2 + $3}'
++ cluma=125.558
++ loops=1
+++ printf %.0f 125.558
++ '[' 126 -le 100 ']'
++ echo '\e[38;2;61;177;30m'
+ USRC='\e[38;2;61;177;30m'
+ NIGH='\e[38;2;200;107;209m'
+ MORN='\e[38;2;255;164;74m'
+ AFTN='\e[38;2;250;245;110m'
+ EVEN='\e[38;2;171;54;3m'
+ greetings=("Welcome" "Greetings" "Hello" "Hi")
+ randgreeting=off
+ twelvehour=on
+ rechargenotif=off
+ updatecheck=on
+ flatpakupd=off
+ goodgreeting=on
+ source /home/tom/.welcome/config.cfg
++ greetings=("Welcome" "Greetings" "Hello" "Hi")
++ randgreeting=on
++ twelvehour=off
++ rechargenotif=on
++ updatecheck=off
++ flatpakupd=off
++ goodgreeting=on
++ displaydate=off
++ NCOL='\e[0m'
++ BOLD='\e[1m'
++ ITAL='\e[3m'
++ UNDR='\e[4m'
++ BLNK='\e[5m'
++ CRIT='\e[31m'
++ LOW='\e[33m'
++ NORM='\e[32m'
++ FULL='\e[3;4;92m'
++ TIME='\e[38;2;224;146;252;1m'
++ DATE='\e[38;2;50;168;82;1m'
+++ randcolor
+++ cluma=0
+++ loops=0
++++ printf %.0f 0
+++ '[' 0 -le 100 ']'
+++ '[' 0 -le 10 ']'
+++ cr=30
++++ echo '30 0.299'
++++ awk '{print $1 * $2}'
+++ crl=8.97
+++ cg=226
++++ echo '226 0.587'
++++ awk '{print $1 * $2}'
+++ cgl=132.662
+++ cb=17
++++ echo '17 0.114'
++++ awk '{print $1 * $2}'
+++ cbl=1.938
++++ echo '8.97 132.662 1.938'
++++ awk '{print $1 + $2 + $3}'
+++ cluma=143.57
+++ loops=1
++++ printf %.0f 143.57
+++ '[' 144 -le 100 ']'
+++ echo '\e[38;2;30;226;17m'
++ USRC='\e[38;2;30;226;17m'
++ NIGH='\e[38;2;200;107;209m'
++ MORN='\e[38;2;255;164;74m'
++ AFTN='\e[38;2;250;245;110m'
++ EVEN='\e[38;2;171;54;3m'
++ cfgversion=2
+ welcome
+ msg=Welcome
+ greetingsLength=4
+ greetingsNumber=1
+ command -v whoami
++ whoami
+ usr=tom
+ '[' on = on ']'
+ msg=Greetings
+ echo -en 'Greetings, \e[38;2;30;226;17m\e[1mtom\e[0m. '
Greetings, tom. + greeting
++ date +%H
+ hour=16
+ greet='It'\''s'
+ '[' on = on ']'
+ greet=Good
+ '[' 16 -le 11 ']'
+ '[' 16 -eq 12 ']'
+ '[' 16 -le 17 ']'
+ '[' 16 -gt 12 ']'
+ echo -en 'Good \e[38;2;250;245;110mafternoon\e[0m. '
Good afternoon. + clock
+ bksp=
+ '[' off = on ']'
++ date +%H
+ hour=16
+ bksp='\b \b'
++ date +%M
+ minute=04
+ echo -en 'The time is \e[38;2;224;146;252;1m16\e[5m:\e[0m\e[38;2;224;146;252;1m04 \b \b\e[0m. '
The time is 16:04. + battery
+ batlvl=0
+ [[ -a /sys/class/power_supply/BAT0/capacity ]]
++ cat /sys/class/power_supply/BAT0/capacity
+ batlvl=83
+ [[ 83 -ge 100 ]]
+ [[ 83 -gt 0 ]]
+ echo -en 'The battery level is '
The battery level is + [[ 83 -le 15 ]]
+ '[' 83 -le 30 ']'
+ echo -en '\e[32m83%\e[0m. '
83%. + '[' off = on ']'
+ echo

+ set +e
++ date +%s
+ date=1678205092
++ cat /home/tom/.welcome/udm
+ lastdate=1678191863
+ [[ 13229 -ge 86400 ]]
+ [[ -f /home/tom/.welcome/udm ]]

zsh output

+/etc/zsh/zshenv:15> [[ -z /usr/sbin:/home/tom/.local/bin:/home/tom/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games || /usr/sbin:/home/tom/.local/bin:/home/tom/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games == /bin:/usr/bin ]]
+/home/tom/.zshenv:1> . /home/tom/.cargo/env
+/home/tom/.cargo/env:4> case :/usr/sbin:/home/tom/.local/bin:/home/tom/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games: (*:/home/tom/.cargo/bin:*)
+/home/tom/.welcome/welcome.sh:1> export LC_NUMERIC=en_US.UTF-8
+/home/tom/.welcome/welcome.sh:4> environment=+/home/tom/.welcome/welcome.sh:4> ps -o 'args=' -p 71246
+/home/tom/.welcome/welcome.sh:4> environment=+/home/tom/.welcome/welcome.sh:4> grep -Em 1 -o '\w{0,5}sh'
+/home/tom/.welcome/welcome.sh:4> environment=+/home/tom/.welcome/welcome.sh:4> head -1
+/home/tom/.welcome/welcome.sh:4> environment=zsh
+/home/tom/.welcome/welcome.sh:5> version=1.1.1
+/home/tom/.welcome/welcome.sh:219> NCOL='\e[0m'
+/home/tom/.welcome/welcome.sh:220> BOLD='\e[1m'
+/home/tom/.welcome/welcome.sh:221> ITAL='\e[3m'
+/home/tom/.welcome/welcome.sh:222> UNDR='\e[4m'
+/home/tom/.welcome/welcome.sh:223> BLNK='\e[5m'
+/home/tom/.welcome/welcome.sh:226> CRIT='\e[31m'
+/home/tom/.welcome/welcome.sh:227> LOW='\e[33m'
+/home/tom/.welcome/welcome.sh:228> NORM='\e[32m'
+/home/tom/.welcome/welcome.sh:229> FULL='\e[3;4;92m'
+/home/tom/.welcome/welcome.sh:231> TIME='\e[38;2;224;146;252;1m'
+/home/tom/.welcome/welcome.sh:232> DATE='\e[38;2;50;168;82;1m'
+/home/tom/.welcome/welcome.sh:233> USRC=+/home/tom/.welcome/welcome.sh:233> randcolor
+randcolor:4> cluma=0
+randcolor:5> loops=0
+randcolor:6> printf %.0f 0
+randcolor:6> [ 0 -le 100 ']'
+randcolor:6> [ 0 -le 10 ']'
+randcolor:7> cr=17
+randcolor:8> crl=+randcolor:8> echo '17 0.299'
+randcolor:8> crl=+randcolor:8> awk '{print $1 * $2}'
+randcolor:8> crl=5.083
+randcolor:9> cg=242
+randcolor:10> cgl=+randcolor:10> echo '242 0.587'
+randcolor:10> cgl=+randcolor:10> awk '{print $1 * $2}'
+randcolor:10> cgl=142.054
+randcolor:11> cb=182
+randcolor:12> cbl=+randcolor:12> echo '182 0.114'
+randcolor:12> cbl=+randcolor:12> awk '{print $1 * $2}'
+randcolor:12> cbl=20.748
+randcolor:13> cluma=+randcolor:13> echo '5.083 142.054 20.748'
+randcolor:13> cluma=+randcolor:13> awk '{print $1 + $2 + $3}'
+randcolor:13> cluma=167.885
+randcolor:14> loops=1
+randcolor:6> printf %.0f 167.885
+randcolor:6> [ 168 -le 100 ']'
+randcolor:16> echo '\e[38;2;17;242;182m'
+/home/tom/.welcome/welcome.sh:233> USRC=$'\C-[[38;2;17;242;182m'
+/home/tom/.welcome/welcome.sh:236> NIGH='\e[38;2;200;107;209m'
+/home/tom/.welcome/welcome.sh:237> MORN='\e[38;2;255;164;74m'
+/home/tom/.welcome/welcome.sh:238> AFTN='\e[38;2;250;245;110m'
+/home/tom/.welcome/welcome.sh:239> EVEN='\e[38;2;171;54;3m'
+/home/tom/.welcome/welcome.sh:241> greetings=( Welcome Greetings Hello Hi )
+/home/tom/.welcome/welcome.sh:242> randgreeting=off
+/home/tom/.welcome/welcome.sh:243> twelvehour=on
+/home/tom/.welcome/welcome.sh:244> rechargenotif=off
+/home/tom/.welcome/welcome.sh:245> updatecheck=on
+/home/tom/.welcome/welcome.sh:246> flatpakupd=off
+/home/tom/.welcome/welcome.sh:247> goodgreeting=on
+/home/tom/.welcome/welcome.sh:251> source /home/tom/.welcome/config.cfg
+/home/tom/.welcome/config.cfg:9> greetings=( Welcome Greetings Hello Hi )
+/home/tom/.welcome/config.cfg:10> randgreeting=on
+/home/tom/.welcome/config.cfg:11> twelvehour=off
+/home/tom/.welcome/config.cfg:12> rechargenotif=on
+/home/tom/.welcome/config.cfg:13> updatecheck=off
+/home/tom/.welcome/config.cfg:14> flatpakupd=off
+/home/tom/.welcome/config.cfg:15> goodgreeting=on
+/home/tom/.welcome/config.cfg:16> displaydate=off
+/home/tom/.welcome/config.cfg:19> NCOL='\e[0m'
+/home/tom/.welcome/config.cfg:20> BOLD='\e[1m'
+/home/tom/.welcome/config.cfg:21> ITAL='\e[3m'
+/home/tom/.welcome/config.cfg:22> UNDR='\e[4m'
+/home/tom/.welcome/config.cfg:23> BLNK='\e[5m'
+/home/tom/.welcome/config.cfg:26> CRIT='\e[31m'
+/home/tom/.welcome/config.cfg:27> LOW='\e[33m'
+/home/tom/.welcome/config.cfg:28> NORM='\e[32m'
+/home/tom/.welcome/config.cfg:29> FULL='\e[3;4;92m'
+/home/tom/.welcome/config.cfg:31> TIME='\e[38;2;224;146;252;1m'
+/home/tom/.welcome/config.cfg:32> DATE='\e[38;2;50;168;82;1m'
+/home/tom/.welcome/config.cfg:33> USRC=+/home/tom/.welcome/config.cfg:33> randcolor
+randcolor:4> cluma=0
+randcolor:5> loops=0
+randcolor:6> printf %.0f 0
+randcolor:6> [ 0 -le 100 ']'
+randcolor:6> [ 0 -le 10 ']'
+randcolor:7> cr=17
+randcolor:8> crl=+randcolor:8> echo '17 0.299'
+randcolor:8> crl=+randcolor:8> awk '{print $1 * $2}'
+randcolor:8> crl=5.083
+randcolor:9> cg=242
+randcolor:10> cgl=+randcolor:10> echo '242 0.587'
+randcolor:10> cgl=+randcolor:10> awk '{print $1 * $2}'
+randcolor:10> cgl=142.054
+randcolor:11> cb=182
+randcolor:12> cbl=+randcolor:12> echo '182 0.114'
+randcolor:12> cbl=+randcolor:12> awk '{print $1 * $2}'
+randcolor:12> cbl=20.748
+randcolor:13> cluma=+randcolor:13> echo '5.083 142.054 20.748'
+randcolor:13> cluma=+randcolor:13> awk '{print $1 + $2 + $3}'
+randcolor:13> cluma=167.885
+randcolor:14> loops=1
+randcolor:6> printf %.0f 167.885
+randcolor:6> [ 168 -le 100 ']'
+randcolor:16> echo '\e[38;2;17;242;182m'
+/home/tom/.welcome/config.cfg:33> USRC=$'\C-[[38;2;17;242;182m'
+/home/tom/.welcome/config.cfg:36> NIGH='\e[38;2;200;107;209m'
+/home/tom/.welcome/config.cfg:37> MORN='\e[38;2;255;164;74m'
+/home/tom/.welcome/config.cfg:38> AFTN='\e[38;2;250;245;110m'
+/home/tom/.welcome/config.cfg:39> EVEN='\e[38;2;171;54;3m'
+/home/tom/.welcome/config.cfg:41> cfgversion=2
+/home/tom/.welcome/welcome.sh:253> welcome
+welcome:1> msg=Welcome
+welcome:2> greetingsLength=4
+welcome:3> greetingsNumber=2
+welcome:5> command -v whoami
+welcome:6> usr=+welcome:6> whoami
+welcome:6> usr=tom
+welcome:13> [ on '=' on ']'
+welcome:14> msg=Greetings
+welcome:18> echo -en $'Greetings, \C-[[38;2;17;242;182m\\e[1mtom\\e[0m. '
Greetings, tom. +/home/tom/.welcome/welcome.sh:254> greeting
+greeting:2> hour=+greeting:2> date +%H
+greeting:2> hour=16
+greeting:3> greet='It'\''s'
+greeting:5> [ on '=' on ']'
+greeting:6> greet=Good
+greeting:10> [ 16 -le 11 ']'
+greeting:12> [ 16 -eq 12 ']'
+greeting:14> [ 16 -le 17 ']'
+greeting:14> [ 16 -gt 12 ']'
+greeting:15> echo -en 'Good \e[38;2;250;245;110mafternoon\e[0m. '
Good afternoon. +/home/tom/.welcome/welcome.sh:255> clock
+clock:1> bksp=''
+clock:3> [ off '=' on ']'
+clock:11> hour=+clock:11> date +%H
+clock:11> hour=16
+clock:12> bksp='\b \b'
+clock:14> minute=+clock:14> date +%M
+clock:14> minute=06
+clock:17> echo -en 'The time is \e[38;2;224;146;252;1m16\e[5m:\e[0m\e[38;2;224;146;252;1m06 \b \b\e[0m. '
The time is 16:06. +/home/tom/.welcome/welcome.sh:256> battery
+battery:3> batlvl=0
+battery:6> [[ -a /sys/class/power_supply/BAT0/capacity ]]
+battery:7> batlvl=+battery:7> cat /sys/class/power_supply/BAT0/capacity
+battery:7> batlvl=84
+battery:17> [[ 84 -ge 100 ]]
+battery:19> [[ 84 -gt 0 ]]
+battery:20> echo -en 'The battery level is '
The battery level is +battery:21> [[ 84 -le 15 ]]
+battery:26> [ 84 -le 30 ']'
+battery:29> echo -en '\e[32m84%\e[0m. '
84%. +/home/tom/.welcome/welcome.sh:257> [ off '=' on ']'
+/home/tom/.welcome/welcome.sh:260> echo

+/home/tom/.welcome/welcome.sh:262> set +e
+/home/tom/.welcome/welcome.sh:264> date=+/home/tom/.welcome/welcome.sh:264> date +%s
+/home/tom/.welcome/welcome.sh:264> date=1678205197
+/home/tom/.welcome/welcome.sh:265> lastdate=+/home/tom/.welcome/welcome.sh:265> cat /home/tom/.welcome/udm
+/home/tom/.welcome/welcome.sh:265> lastdate=1678191863
+/home/tom/.welcome/welcome.sh:267> [[ 13334 -ge 86400 ]]
+/home/tom/.welcome/welcome.sh:274> [[ -f /home/tom/.welcome/udm ]]
commented

I can't seem to reproduce this problem unfortunately

commented

Try reinstalling I suppose

It has always happened, just thought I'd mention it. It seems to be trying to pull an extra welcome value that doesn't exist and printing nothing instead. Only happens sometimes, like blank is in the value list.

commented

I'll open an issue for it. If you could get an output of the bash -x ~/.welcome/welcome.sh command when the error occurs that would be perfect.

+ export LC_NUMERIC=en_US.UTF-8
++ ps -o args= -p 73732
++ grep -Em 1 -o '\w{0,5}sh'
++ head -1
+ environment=bash
+ version=1.1.1
+ NCOL='\e[0m'
+ BOLD='\e[1m'
+ ITAL='\e[3m'
+ UNDR='\e[4m'
+ BLNK='\e[5m'
+ CRIT='\e[31m'
+ LOW='\e[33m'
+ NORM='\e[32m'
+ FULL='\e[3;4;92m'
+ TIME='\e[38;2;224;146;252;1m'
+ DATE='\e[38;2;50;168;82;1m'
++ randcolor
++ cluma=0
++ loops=0
+++ printf %.0f 0
++ '[' 0 -le 100 ']'
++ '[' 0 -le 10 ']'
++ cr=65
+++ echo '65 0.299'
+++ awk '{print $1 * $2}'
++ crl=19.435
++ cg=244
+++ echo '244 0.587'
+++ awk '{print $1 * $2}'
++ cgl=143.228
++ cb=85
+++ echo '85 0.114'
+++ awk '{print $1 * $2}'
++ cbl=9.69
+++ echo '19.435 143.228 9.69'
+++ awk '{print $1 + $2 + $3}'
++ cluma=172.353
++ loops=1
+++ printf %.0f 172.353
++ '[' 172 -le 100 ']'
++ echo '\e[38;2;65;244;85m'
+ USRC='\e[38;2;65;244;85m'
+ NIGH='\e[38;2;200;107;209m'
+ MORN='\e[38;2;255;164;74m'
+ AFTN='\e[38;2;250;245;110m'
+ EVEN='\e[38;2;171;54;3m'
+ greetings=("Welcome" "Greetings" "Hello" "Hi")
+ randgreeting=off
+ twelvehour=on
+ rechargenotif=off
+ updatecheck=on
+ flatpakupd=off
+ goodgreeting=on
+ source /home/tom/.welcome/config.cfg
++ greetings=("Welcome" "Greetings" "Hello" "Hi")
++ randgreeting=on
++ twelvehour=off
++ rechargenotif=on
++ updatecheck=off
++ flatpakupd=off
++ goodgreeting=on
++ displaydate=off
++ NCOL='\e[0m'
++ BOLD='\e[1m'
++ ITAL='\e[3m'
++ UNDR='\e[4m'
++ BLNK='\e[5m'
++ CRIT='\e[31m'
++ LOW='\e[33m'
++ NORM='\e[32m'
++ FULL='\e[3;4;92m'
++ TIME='\e[38;2;224;146;252;1m'
++ DATE='\e[38;2;50;168;82;1m'
+++ randcolor
+++ cluma=0
+++ loops=0
++++ printf %.0f 0
+++ '[' 0 -le 100 ']'
+++ '[' 0 -le 10 ']'
+++ cr=164
++++ echo '164 0.299'
++++ awk '{print $1 * $2}'
+++ crl=49.036
+++ cg=55
++++ echo '55 0.587'
++++ awk '{print $1 * $2}'
+++ cgl=32.285
+++ cb=82
++++ echo '82 0.114'
++++ awk '{print $1 * $2}'
+++ cbl=9.348
++++ echo '49.036 32.285 9.348'
++++ awk '{print $1 + $2 + $3}'
+++ cluma=90.669
+++ loops=1
++++ printf %.0f 90.669
+++ '[' 91 -le 100 ']'
+++ '[' 1 -le 10 ']'
+++ cr=193
++++ echo '193 0.299'
++++ awk '{print $1 * $2}'
+++ crl=57.707
+++ cg=127
++++ echo '127 0.587'
++++ awk '{print $1 * $2}'
+++ cgl=74.549
+++ cb=236
++++ echo '236 0.114'
++++ awk '{print $1 * $2}'
+++ cbl=26.904
++++ echo '57.707 74.549 26.904'
++++ awk '{print $1 + $2 + $3}'
+++ cluma=159.16
+++ loops=2
++++ printf %.0f 159.16
+++ '[' 159 -le 100 ']'
+++ echo '\e[38;2;193;127;236m'
++ USRC='\e[38;2;193;127;236m'
++ NIGH='\e[38;2;200;107;209m'
++ MORN='\e[38;2;255;164;74m'
++ AFTN='\e[38;2;250;245;110m'
++ EVEN='\e[38;2;171;54;3m'
++ cfgversion=2
+ welcome
+ msg=Welcome
+ greetingsLength=4
+ greetingsNumber=3
+ command -v whoami
++ whoami
+ usr=tom
+ '[' on = on ']'
+ msg=Hi
+ echo -en 'Hi, \e[38;2;193;127;236m\e[1mtom\e[0m. '
Hi, tom. + greeting
++ date +%H
+ hour=16
+ greet='It'\''s'
+ '[' on = on ']'
+ greet=Good
+ '[' 16 -le 11 ']'
+ '[' 16 -eq 12 ']'
+ '[' 16 -le 17 ']'
+ '[' 16 -gt 12 ']'
+ echo -en 'Good \e[38;2;250;245;110mafternoon\e[0m. '
Good afternoon. + clock
+ bksp=
+ '[' off = on ']'
++ date +%H
+ hour=16
+ bksp='\b \b'
++ date +%M
+ minute=15
+ echo -en 'The time is \e[38;2;224;146;252;1m16\e[5m:\e[0m\e[38;2;224;146;252;1m15 \b \b\e[0m. '
The time is 16:15. + battery
+ batlvl=0
+ [[ -a /sys/class/power_supply/BAT0/capacity ]]
++ cat /sys/class/power_supply/BAT0/capacity
+ batlvl=88
+ [[ 88 -ge 100 ]]
+ [[ 88 -gt 0 ]]
+ echo -en 'The battery level is '
The battery level is + [[ 88 -le 15 ]]
+ '[' 88 -le 30 ']'
+ echo -en '\e[32m88%\e[0m. '
88%. + '[' off = on ']'
+ echo

+ set +e
++ date +%s
+ date=1678205711
++ cat /home/tom/.welcome/udm
+ lastdate=1678191863
+ [[ 13848 -ge 86400 ]]
+ [[ -f /home/tom/.welcome/udm ]]

Run a few times now, seems to always happen with 'Hi'

+ usr=tom
+ '[' on = on ']'
+ msg=Hi
+ echo -en 'Hi, \e[38;2;193;127;236m\e[1mtom\e[0m. '
Hi, tom. + greeting
commented

Thanks, I found the issue. Please move to #6