Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: "script" trickery



On Feb 16,  4:10am, Meino Christian Cramer wrote:
}
}  I tried to write a shell function for my .zshrc which first checks 
}  for the existence of the given file and then starts script.
} 
}  But that fails due to the fact that "script" seems to start a subshel
}  or do other trickery.

Well, yes, it starts a subshell, but that shouldn't prevent a function
in the calling shell from testing for the existence of the file before
script even gets started.

    function script {
      emulate -L zsh
      setopt noclobber
      zmodload -i zsh/zutil
      local -a opts
      zparseopts -D -a opts a c: f q t  
      set -- "${@:-typescript}"
      if [[ -e $1 ]]; then
        print -u2 script: file exists: $1
	return 1
      fi
      command script $opts $*
    }
 



Messages sorted by: Reverse Date, Date, Thread, Author