سؤال

I'm writing a simple function for fish-shell that should behave like this :

theFunc someArguments
somecommand | theFunc

I looking for a way to know if the function was called with a pipe / redirection or not.
Do you have an idea SO?

Thanks!

هل كانت مفيدة؟

المحلول

I'm setting the informations if anyone needs it.

As Ben Voigt pointed it out, we should use the isatty function.
For fish-shell you can simply check:

if isatty stdin
    # Your code here.
end
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top