7

I use the command:

cm1 cm2 arg1 arg2 'argument 3'

It first goes to cm1, which will then redirect arg1 arg2 'argument 3' to another file.

/usr/bin/cm1:

#! /bin/bash
# some script here
shift
cm2 $@

/usr/bin/cm2:

echo $#
# This returns 4 in lieu of 3 because the white space in 'argument 3' causes the argument to be split into two arguments.

So, how can I pass arguments from one script to another and make sure white space won't be read as an argument separator?

slhck
  • 235,242

1 Answers1

8

I assume you have to re-wrap it into quotes, like so:

#! /bin/bash
# some script here
shift
cm2 "$@"
Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311