Skip to content

fish: Expected a string, but found a redirection #9886

Closed Answered by faho
Randommist asked this question in Q&A
Discussion options

You must be logged in to vote

Fish does not support running redirections without a command. This is an awkward special case in bash's grammar (actually the POSIX shell grammar) without any real need, and so it's not something fish does.

Use touch filename or : >filename. The latter of which is what bash will do implicitly.

One upside of not having this special case is that it allows you to find errors. E.g. if you accidentally do foo & >file instead of foo >file & that will error out rather than running foo with the wrong stdout.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zanchey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants