I am doing something I always do in Bash:
set | grep -i path
and the output is
Binary file (standard input) matches
What's wrong? grep --help
works, and set | more
works too.
Do this:
set > /tmp/zshset
Then open /tmp/zshset
in your favorite editor. Look for IFS
.
The default value for this, per the zshparam
man page, is default space, tab, newline and NUL. This last one is causing the trouble. grep
sees the NUL (ascii 0, displayed often as ^@
) and thinks that this is a binary file.
Possible solutions:
grep -a
as suggested by KeithB (or its equivalent --binary-files=text
)grep -a
to save yourself a little bit of typingenv | grep -i path
, echo $PATH
) -- I think the other solutions are simplerI'm not sure what is going on, but you can pass the -a
flag to grep to force it to treat its input as text, regardless of what it thinks that it is.
grep --binary-files=text
which works, but I wonder why this doesn't work off the bat.... Thanks
May 17, 2010 at 13:56
Another workaround if your grep
doesn't implement -a
is to do:
$ set | cat -v | grep foo