mko
mko

Reputation: 22064

Pre-character escaping in bash

I read this article, in the part

### NO NO NO: this passes three strings:
###      (1)  "my
###      (2)  multiword
###      (3)  argument"
MYARG="\"my multiword argument\""
somecommand $MYARG

### THIS IS NOT (!!!!) THE SAME AS ###
command "my multiword argument"

### YOU NEED ###
MYARG="my multiword argument"
command "$MYARG"

both of method interpret as a full string, different from what it says in the article:

test.bash

#! /bin/bash
echo $1

./test.bash "\"my good ness\""
"my good ness"

Upvotes: 0

Views: 64

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798676

You're passing it directly as an argument, rather than putting it in a variable and passing that. There is no valid comparison between the two methods.

Upvotes: 1

Related Questions