Arc Forumnew | comments | leaders | submitlogin
1 point by laughingboy 6163 days ago | link | parent

This works great, but what exactly does `"$0" ${1+"$@"}` mean? I'm not a keen shell scripter.


4 points by bayareaguy 6163 days ago | link

This is the common sh shell idiom to properly pass the original command line to the program being invoked.

"$0" expands to the program name ("ar.sh" in his example).

${1+"$@"} is conditional:

if $1 (the first positional parameter) is unset it expands to nothing.

however if $1 is set, it expands to "$@", which in turn expands to all the parameters, each one quoted as a separate word.

-----

1 point by laughingboy 6163 days ago | link

Thank you.

-----

1 point by byronsalty 6148 days ago | link

I'm wondering about this #| .. |# syntax. Never seen that before.

-----

2 points by cadaver 6148 days ago | link

It's the scheme way to write multiline comments (possibly other lisps?). It's specified in the R6RS.

-----

1 point by kennytilton 6148 days ago | link

Also Common Lisp, and this reminds me that this is something I missed when working on some Arc code.

-----

2 points by cadaver 6148 days ago | link

#| ... |# works in Arc too. Though whether by design or because mzscheme supports it, I don't know.

-----

1 point by kennytilton 6147 days ago | link

Doh! :)

-----