mklement0 / ttab

macOS and Linux CLI for opening a new terminal tab/window, optionally with a command to execute and/or display settings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quoted commands fail

brandondrew opened this issue · comments

Certain commands are not (AFAIK) possible with ttab, because of precedence rules.

ttab -t 'code & git' (git branch; git status)
ttab -t 'code & git' (git branch && git status)

It might seem that putting quotes around the command would fix this, passing it all to ttab as a single argument that could be unpacked before being issued to the shell, but it does not work.

Allowing the command and its arguments to be either single or double quoted (but not requiring it!) would be very helpful, as it would allow commands like those given above to succeed.

The man page states (emphasis added):

To specify multiple commands, use eval followed by a single, quoted
string
containing the entire shell command line to execute; in the simplest
case, enclose the string in single-quotes and use ; to separate com-
mands.

Thus, you'd have to specify

 ttab -t 'code & git' eval 'git branch && git status'

I realized that I could make the eval implicit, so if you install the just-released v0.5.0), you can omit it:

 ttab -t 'code & git' 'git branch && git status'

In other words: you can now pass any shell command line as a single, quoted string as the one and only operand (non-option) to ttab to have it executed in the new tab.

Note that quoting the command line is invariably a requirement, as the current shell would otherwise interpret metacharacters such as ;, (, ) and &, before ttab ever gets to see the command.