tcsh-org / tcsh

This is a read-only mirror of the tcsh code repository.
https://www.tcsh.org/
Other
229 stars 42 forks source link

Variable assignment from pipes and redirections #105

Open Krush206 opened 1 month ago

Krush206 commented 1 month ago

In recognition of Bourne-compatible Shells and Mashey Shell, I came up with an implementation for assigning variables from pipes and redirections. Normal assignment reads until EOF or a newline is found. Indexed assignment reads until EOF. This is implemented for environment variable assignment as well. In order to avoid confusion with manual assignment, assignment from pipes and redirections is only possible if the variable name doesn't precede the assignment operator [equal sign]. This means subsequent names in a single command (e.g: set a b c) will be assigned from a pipe or redirection. If the name precedes the assignment operator, subsequent names, even if preceded or not by the assignment operator, won't read from a pipe or redirection.

This work also provides a fix for pipes and piped built-ins, at the cost of having piped built-ins forked. I don't think this cost should be taken badly, since most (if not all) Bourne-compatible Shells fork piped built-ins. The fix remedies the issue regarded here, on blank output from pipes.