Re: `printf -v foo ""` does not set foo=
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 6/24/13 6:52 PM, Mike Frysinger wrote: > On Monday 24 June 2013 16:13:01 Chet Ramey wrote: >> On 6/17/13 1:27 AM, Mike Frysinger wrote: >>> simple test code: >>> unset foo >>> printf -v foo "" >>> echo ${foo+set} >>> >>> that does not display "set". seems to have been this way since the >>> feature was added in bash-3.1. >> >> printf returns immediately if the format string is null. It has always >> been implemented this way. > > seems like when the -v arg is in use, that [otherwise reasonable] shortcut > should be not taken ? Maybe. I'll take a look. I suspect that the amount of code that depends on the current behavior is pretty small. Chet - -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlHJoPcACgkQu1hp8GTqdKskTQCfatq1LQuEh6oPEl55Ljqarf1T HGsAnA6fPLj+bP8LIqeSbayFne6HOkR4 =9mwl -END PGP SIGNATURE-
Re: corrupted input after size function (input that's not recorded by bash)
On 6/13/13 3:58 PM, Linda Walsh wrote: > > I have a small function in my bashrc: > > function showsize () {\ > local s=$(stty size); local o="(${s% *}x${s#* })"; s="${#o}";\ > echo -n $o; while ((s-- > 0));do echo -ne "\b"; done; \ > } > export -f showsize > trap showsize SIGWINCH > --- > That has the effect of showing me my current window size > when I resize it. > > The odd thing is, if I use it while at a bash input prompt -- > any command I type has the first word ignored. I haven't looked closely at this yet, but I bet that bash-4.2 running the trap immediately when the SIGWINCH is received is screwing up the parser state. A quick test shows me that running this on an empty line, then hitting return after resizing the terminal and before entering a new command, does not result in any errors. This won't work in bash-4.3, which runs traps at command boundaries to avoid just this kind of corruption. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: How to test if a link exists
Dave & John, thank you both. I think you are both right that my solution is [ -a file -o -h file ] || echo "ok to create file" However I personally feel that there ought be a simple test for this situation, there are still a few spare letters that could be used for the test ;) I'm willing to bet there is plenty of code out there that tries to decide whether it is safe to create a file and would fall foul of an errant dead symbolic link. A little off topic but are -a and -e identical? Cheers, mark