各コマンドの-eオプションをそろえる

.bashrcに以下を書く

function gosh(){ if [ $# -ge 1 ] && [ $1 == '-e' ]; then echo "$2">$$.scm;shift 2;`which gosh` $$.scm "$@";rm $$.scm; else rlwrap `which gosh` "$@";fi }
function runghc(){ if [ $# -ge 1 ] && [ $1 == '-e' ]; then echo "$2">$$.hs;shift 2;`which runghc` $$.hs "$@";rm $$.hs; else `which runghc` "$@";fi }
function js(){ if [ $# -ge 1 ] && [ $1 == '-e' ]; then echo "$2">$$.js;shift 2;`which js` $$.js "$@";rm $$.js; else `which js` "$@";fi }


それぞれの実行結果

$ gosh -e '(print "helloworld")'
helloworld
$ runghc -e 'main=do{putStrLn "helloworld"}'
helloworld
$ js -e 'print("helloworld")'
helloworld

いまいちrunghcがおかしい気がする。(修正済)

追記6/29:絶対パス(which)でコマンドを書き直した
追記7/1:引数の"$2"と"$*"を修正。
追記7/3:引数が0の時の挙動がおかしかったので "$*"を"$@"にした。