Skip to content

bashrun

Usage
bashrun [--] <code>

Runs a snippet of Bash code in a child bash attached to the terminal, so output streams live and interactive programs work, then carries its exported-variable changes and its final directory back into the current Fish session. Unlike replay, nothing is buffered, but Bash aliases and functions are not carried back.

Enter calls this automatically for a command line that Fish cannot parse but Bash can (see __bashrun_execute), rewriting the line to bashrun ‘<code>’ first so the history entry shows what actually ran.

Bash’s $? starts as the status of the Fish command run just before.

code Bash code to run; several arguments are joined with spaces
-h, --help Show usage help (only as the sole argument)

The exit status of the Bash code 2 No code given, an unknown option, or bash is not installed

Terminal window
bashrun 'for f in *.log; do gzip "$f"; done'
bashrun 'export FOO=bar; cd /tmp'

Classification: bypasses-shadow(bash)