Skip to main content
added 289 characters in body
Source Link
Stéphane Chazelas
  • 584.8k
  • 96
  • 1.1k
  • 1.7k

sh_in_stdin is not on whilst interpreting ~/.zshenv, or when interpreting any sourced file (in those cases, the shell code is not coming from stdin). You can verify it by adding echo $options[shinstdin] to your ~/.zshenv, or running:

$ echo 'echo $options[shinstdin]; source =(<<<"echo \$options[shinstdin]")' | zsh
on
off

You could instead check that $PPID is running atd:

if [[ $(ps -o comm= -p $PPID) = atd ]]; then...

Personally, I don't like the idea of doing it unconditionally for every zsh invocation run from atd.

You could always define a debug-at command that does:

debug-at() {
  {
    echo 'PS4="> "; set -o verbose -o xtrace'
    cat
  } | at "$@"
}

And use that instead of at when you do want an at/batch job to run with debugging on.

Beware that not all systems use $SHELL to interpret the supplied code. Debian's at doesn't. POSIX leaves it implementation-defined. The above approach would work regardless of what shell is used (as long as it's Korn/POSIX-like).

sh_in_stdin is not on whilst interpreting ~/.zshenv.

You could instead check that $PPID is running atd:

if [[ $(ps -o comm= -p $PPID) = atd ]]; then...

Personally, I don't like the idea of doing it unconditionally for every zsh invocation run from atd.

You could always define a debug-at command that does:

debug-at() {
  {
    echo 'PS4="> "; set -o verbose -o xtrace'
    cat
  } | at "$@"
}

And use that instead of at when you do want an at/batch job to run with debugging on.

sh_in_stdin is not on whilst interpreting ~/.zshenv, or when interpreting any sourced file (in those cases, the shell code is not coming from stdin). You can verify it by adding echo $options[shinstdin] to your ~/.zshenv, or running:

$ echo 'echo $options[shinstdin]; source =(<<<"echo \$options[shinstdin]")' | zsh
on
off

You could instead check that $PPID is running atd:

if [[ $(ps -o comm= -p $PPID) = atd ]]; then...

Personally, I don't like the idea of doing it unconditionally for every zsh invocation run from atd.

You could always define a debug-at command that does:

debug-at() {
  {
    echo 'PS4="> "; set -o verbose -o xtrace'
    cat
  } | at "$@"
}

And use that instead of at when you do want an at/batch job to run with debugging on.

Beware that not all systems use $SHELL to interpret the supplied code. Debian's at doesn't. POSIX leaves it implementation-defined. The above approach would work regardless of what shell is used (as long as it's Korn/POSIX-like).

Source Link
Stéphane Chazelas
  • 584.8k
  • 96
  • 1.1k
  • 1.7k

sh_in_stdin is not on whilst interpreting ~/.zshenv.

You could instead check that $PPID is running atd:

if [[ $(ps -o comm= -p $PPID) = atd ]]; then...

Personally, I don't like the idea of doing it unconditionally for every zsh invocation run from atd.

You could always define a debug-at command that does:

debug-at() {
  {
    echo 'PS4="> "; set -o verbose -o xtrace'
    cat
  } | at "$@"
}

And use that instead of at when you do want an at/batch job to run with debugging on.