I switched the shell on my main account to zsh and when installing a script that logs history to a database, https://github.com/larkery/zsh-histdb, I saw that some typeset commands in them didn't work, and after some searches I changed them to declare and then they worked.

The files in question are https://github.com/larkery/zsh-histdb/blob/master/history-timer.zsh and https://github.com/larkery/zsh-histdb/blob/master/sqlite-history.zsh (at commit 0b89299, 2017-05-01) . The typeset commands in the second one are at the beginning of the file.

What could be the difference between the author's set up and mine that would enable typeset to work on theirs but not on mine?

My usual shell is bash and changed only my regular logon account to zsh and applied the chsh -s $SHELL account to mine, but I don't know if it affects all the other accounts.

ls -l /bin/sh maps to dash.

PS. As files like .bashrc and .zshrc don't contain #!/bin/bash or #!/bin/sh what interpreter runs the commands in the when the user logons or some command requires a shell?


# contents of .zshrc
export ZSH=/home/vfclists/.oh-my-zsh

source $ZSH/oh-my-zsh.sh
if [ -f ~/.profile ]; then
    source ~/.profile

# larkery historydb, https://github.com/larkery/zsh-histdb
# paths must be configured by now
if [ -f ~/bin/sqlite-history.zsh ]; then
    source ~/bin/sqlite-history.zsh
source ~/bin/history-timer.zsh
autoload -Uz add-zsh-hook
add-zsh-hook preexec _start_timer
add-zsh-hook precmd _stop_timer

closed as unclear what you're asking by Gilles, DarkHeart, thrig, Anthon, Rui F Ribeiro May 1 '17 at 6:21

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Both bash and zsh has typeset. dash does not. What shell is your login shell at the moment (look in /etc/passwd)? – Kusalananda Apr 30 '17 at 11:37
  • bash reads ~/.bashrc when starting as an interactive shell. zsh reads ~/.zshrc when starting as an interactive shell. – Kusalananda Apr 30 '17 at 11:44
  • The effect of chsh -s $SHELL` will obviously depend on what SHELL was set to at the time. What does getent passwd "$USER" print for you now (or your local equivalent to see your login shell setting)? – tripleee Apr 30 '17 at 12:17
  • checking the shell in /etc/passwd shows /usr/bin/zsh but echo $SHELL says /bin/bash. When I open a new screen window or a new console in konsole echo $SHELL is /bin/bash but when I do ssh@localhost it is /usr/bin/zsh – vfclists Apr 30 '17 at 13:22
  • 1
    After rebooting and reverting the declare commands back to typeset it works without errors. @Kusalananda's comment about dash may be the reason. When I make the switch on other accounts later I will be careful about the exact reasons. – vfclists May 2 '17 at 9:02