If you want to search for the regexp that is the concatenation of the arguments with space characters in between, that would be:
#! /bin/sh -
IFS=' ' # used for "$*"
grep -r --color=always -e "$*" . | nolong
"$*"
joins the positional parameters with the first character (actually byte except with yash
) of $IFS
.
Note (as you seem to be confused by the meaning of space) that if you run:
myscript hello world
myscript hello world
myscript 'hello' "world"
The spaces (or quotes) are not passed to myscript
, they are just part of the shell command-line syntax. In those 3 shell command lines, myscript
receives the same 3 arguments: "myscript", "hello" and "world".
If you want to search for any of the regexps passed as arguments:
#! /bin/sh -
for i do
set -- "$@" -e "$i"
shift
done
[ "$#" -gt 0 ] && grep -r --color=always "$@" . | nolong