bbzz said:I wanted to try zsh shell, however certain scripts are now not running. Isn't the script interpreted by whatever you have defined in your script eg. #/bin/sh , rather than whatever shell your in?
MEM_PAGE=$(sysctl -n hw.pagesize)
MEM_SIZE=$(( $(sysctl -n vm.stats.vm.v_page_count) * $(MEM_PAGE) / 1024 /1024 ))
### catch when shebang is actually used with nonexistent executable
$ cat >foo.sh <<EOF && chmod +x foo.sh
#!/nonexistent
ps p $$
EOF
$ tcsh -c ./foo.sh
./foo.sh: Command not found.
Exit 1
$ zsh -c ./foo.sh
zsh:1: ./foo.sh: bad interpreter: /nonexistent: no such file or directory
Exit 127
### now, let's break it by removing `!'
$ sed -i '' s/\!// foo.sh
$ cat foo.sh
#/nonexistent
ps p $$
$ tcsh -c ./foo.sh
PID STAT TT TIME COMMAND
33882 S+ 2 0:00.00 /bin/csh ./foo.sh
$ zsh -c ./foo.sh
PID STAT TT TIME COMMAND
33885 S+ 2 0:00.00 sh ./foo.sh
### or just nuke it
$ sed -i '' 1d foo.sh
$ cat foo.sh
ps p $$
$ tcsh -c ./foo.sh
PID STAT TT TIME COMMAND
33895 S+ 2 0:00.00 /bin/sh ./foo.sh
$ zsh -c ./foo.sh
PID STAT TT TIME COMMAND
33897 S+ 2 0:00.00 sh ./foo.sh
$ zsh -c 'echo $(( 3038353 * 4096 / 1024 /1024 ))'
11868
$ sh -c 'echo $(( 3038353 * 4096 / 1024 /1024 ))'
11868
$ echo $((++i))
1
$ echo $((++i))
2
$ echo $((++i))
3
$ (( 1 < 2 )); echo $?
0
$ (( 1 > 2 )); echo $?
1
Try to drop braces around MEM_PAGE as it's not a command but a variable, e.g.bbzz said:MEM_PAGE=$(sysctl -n hw.pagesize)
MEM_SIZE=$(( $(sysctl -n vm.stats.vm.v_page_count) * $(MEM_PAGE) / 1024 /1024 ))
$ MEM_PAGE=$(sysctl -n hw.pagesize)
$ MEM_SIZE=$(( $(sysctl -n vm.stats.vm.v_page_count) * $(MEM_PAGE) / 1024 /1024 ))
MEM_PAGE: not found
arithmetic expression: expecting primary: " 1010646 * / 1024 /1024 "
export PATH="/usr/local/lib/cw:"....
bbzz said:Found the error! Started zsh session without ~/.zshrc and it worked fine. So the issue was in my zsh config file. Unfortunately I'm posting from my laptop so I'm not going to copy the whole file (which had quite a bit of settings in there).
Long story short, there is a line for /sysutils/cw coloring program I use
After removing this it works. For some reason it screws up everything (not sure why).Code:export PATH="/usr/local/lib/cw:"....
I guess it's because of vmstat in there.
Thanks for all the help, appreciate it.
@swallowtail_butterfly
That was typo; it's ${MEM_PAGE} not $(MEM_PAGE)
UNIXgod said:you don't need quotes with PATH