1

I'm trying to write an alias in my ~/.bashrc of this form:

alias a="foo; osascript -e 'tell application "Terminal" to do script "bar"; baz"

(where bar launches in a new Terminal window, as per this question) but this string doesn't look like it will parse. I tried string interpolation (${str}), but the problem seems to be unsolvable that way.

2
  • 1
    That's probably ~/.bashrc (without the underscore). Commented Jul 12, 2010 at 20:40
  • Oops, thanks. Been working in Ruby too much. Corrected. Commented Jul 13, 2010 at 14:44

2 Answers 2

1
alias a="foo; osascript -e 'tell application \"Terminal\" to do script \"bar\"'; baz"
Sign up to request clarification or add additional context in comments.

Comments

0

Surprisingly, the string appears to work fine as written. As long as it's on one line, Bash doesn't terminate the double-quoted string the way you'd expect.

Update: As Ignacio points out, the string as written doesn't preserve the double quotes within it. To wit:

# Good:
a="foo; osascript -e 'tell application \"Terminal\" to do script \"bar\"'; baz"
echo $a
> foo; osascript -e 'tell application "Terminal" to do script "bar"'; baz

# Not so good:
b="foo; osascript -e 'tell application "Terminal" to do script "bar"'; baz"
echo $b
> foo; osascript -e 'tell application Terminal to do script bar'; baz

1 Comment

Nope. But it won't quote those pieces either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.