Say I have a executable myProgram, who takes a filename as one of the arguments, and output a lot of stuff to stdout. Now I want to write a bash script to invoke myProgram and pipe the output to less. Normally I would create a bash script myCommand:
#!/bin/bash
myProgram $* | less
But somehow bash will split any file name with spaces into multiple arguments. For example, it converts
myCommand some\ file -m 5
into
myProgram some file -m 5 | less
which of course causes error. Is there a way to resolve this problem? I tried adding " around $* but then realized that it won't help because it will cause the entire argument list becoming a single argument, which is not what I want.