1
Is it possible to use a shell function in a pipeline?
Say I had a function that acted like grep
, called mygrep
.
Is there any way, using only POSIX shell features, to be able to invoke
mygrep
like this:
if ps | mygrep foo ; then
echo "process foo is running"
fi
Or is piping limited to external commands only?
1What keeps you from trying? – Kamil Maciorowski – 2018-09-19T05:02:26.460
1@KamilMaciorowski: Perhaps the uncertainity in whether it works due to being a standard POSIX feature, or whether it works due to being one of the million ksh/bash/zsh extensions. When OP mentions "using only ...", it's best to assume "Is it supposed to work?" – user1686 – 2018-09-19T07:55:02.343
@grawity A reasonable guess, I get your point. If so, providing results of own tests in few shells would be a nice research effort. – Kamil Maciorowski – 2018-09-19T08:04:31.633
@grawity My answer now addresses this issue. Thank you. – Kamil Maciorowski – 2018-09-19T08:48:53.410