On Mon, 08 Aug 2011 15:56:30 -0700, Linda Walsh wrote: > Michael Witten wrote: >> >> In any case, even if `no_empty_cmd_completion' were to behave as Linda >> expected, her tabs would still get eaten when pasted on the interactive >> command line. > > Which is what Linda expects... the function definition wouldn't > hold spaces or tabs or whitespace unless it is quoted. > > She just doesn't expect, when pasting a function that is from a > source file into her shell, scads of output that is unexpected, > unwanted, and more than a bit confusing. > > Fortunately, if you have the function 'well formed' and 'well > defined', it seems to make no difference as far as defining the > actual function, BUT having all the names of my current dir > blatted out for each tab char is a pain. > > So don't assume or infer that Linda wanted the tabs included in > bash's internal function representation. She just didn't want the > blather. > > Reasonable? Or is someone going to tell me why blather is a > desired and wanted feature (under one standard or another! ;-))...
Reasonable, but naive. Interactive bash can complete variable names, even when they are quoted. On my system, these variables are in the environment: TERM TERMINFO Now, when I try to paste the following ("$TERM<tab>$TERMINFO"): foo() { echo "$TERM $TERMINFO"; } this is the result in my terminal: mfwitten$ foo() { echo "$TERM$TERMINFO"; } which is not what I wanted; if I save that same line in a file and then run a shell on that file, I get the expected output. Similarly, if I paste the following ("$TERM<tab><tab>$TERMINFO"): foo() { echo "$TERM $TERMINFO"; } the result is this in my terminal: mfwitten$ foo() { echo "$TERM $TERM $TERMINFO mfwitten$ foo() { echo "$TERM$TERMINFO"; } Here, the 2 tabs ask bash/readline to print the possible completions for `$TERM' (hence the scads of output) and then the rest of the pasted input gets written in as before. If you want to work with your functions interactively, then just save them to a file (like `/tmp/s') and source them in: mfwitten$ source /tmp/s mfwitten$ foo rxvt-unicode-256color /usr/share/terminfo or, equivalently: mfwitten$ . /tmp/s mfwitten$ foo rxvt-unicode-256color /usr/share/terminfo This is much more efficient than copying and pasting when you need to do a lot of tinkering. If you insist on copying and pasting into an interactive terminal, then never ever use tab characters anywhere.