Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • I found out that [[ -z ${ZSH_EXECUTION_STRING+set} && -z ${ZSH_SCRIPT+set} ]] has the desired effect in .zshenv. Now I've three solutions, I'm not sure yet which I'll use. Perhaps an at function sending to the at executable with command. Commented Jul 13, 2020 at 15:23
  • @AProgrammer, ! (( $+ZSH_EXECUTION_STRING || $+ZSH_SCRIPT )) or ! [[ -v ZSH_EXECUTION_STRING || -v ZSH_SCRIPT ]] would be more zsh'y. Commented Jul 13, 2020 at 15:28
  • Thanks. I'd need a good reference of best practices for shell programming. I've collected some tips along the years, but I do it rarely enough that I've probably forgot half of them, and in the other half I wonder which part is sane, and which is simply cargo cult programming. And then there is the fact that for most scripts I try to be quite portable, but my interactive environment is zsh. Commented Jul 13, 2020 at 15:38
  • Yes, the portable one would be [ -z "${ZSH_EXECUTION_STRING+set}" ] && [ -z "${ZSH_SCRIPT+set}" ], but portability is not relevant here as that's only meant for zsh. Among them, the choice is mostly a matter of taste. Commented Jul 13, 2020 at 15:41