Re: Command substitution (backtick) and tab completion
From:
Greg Wooledge
Subject:
Re: Command substitution (backtick) and tab completion
Date:
Wed, 5 Jan 2011 11:57:15 -0500
User-agent:
Mutt/1.4.2.3i
On Wed, Jan 05, 2011 at 08:21:18AM -0800, chengiz wrote:
> So if I get this right, the only time this is a problem is when the
> command substitution runs more than once.
I'd actually characterize it differently: it's unsafe to run arbitrary
commands during tab completion, because bash doesn't know what those
commands might do.
> When does this happen? Not
> in my "ls `pwd`/<tab>" example where the command runs once and
> replaces itself with its output. Does it only run more than once when
> the ticks are not complete?
You might realize you made a mistake, hit Ctrl-U, and start over. But
the backticked command has already been executed.
You might hit ESC # to comment out the command line because you suddenly
realize that you need to do something else first. Then you come back to
it (ESC k k ...), remove the # sign, finish typing the command, and run
it. But the backticked command was already executed much earlier than
you might have wished (two commands ago).