{"thread":{"id":"14930","subject":"git-bisect: weird usage of read(1)","startedAt":"2008-08-11T13:57:04Z","lastAt":"2008-08-11T19:47:25Z","messageCount":15,"participants":["Francis Moreau","Johannes Schindelin","Mikael Magnusson","Reece Dunn","René Scharfe","Petr Baudis","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"86767","messageId":"38b2ab8a0808110657y24ac9526wca4acea3bddaec00@mail.gmail.com","threadId":"14930","inReplyTo":null,"subject":"git-bisect: weird usage of read(1)","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2008-08-11T13:57:04Z","receivedAt":"2008-08-11T13:57:04Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"Hello\n\nI found this in git bisect:\n\n              printf >&2 'Are you sure [Y/n]? '\n              case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n\nwhich looks very weird since read(1) returns a status and not the\nstring reads from std input.\n\nAm I missing something ?\n\nThanks\n-- \nFrancis\n"},{"id":"86769","messageId":"alpine.DEB.1.00.0808111615260.24820@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"14930","inReplyTo":"38b2ab8a0808110657y24ac9526wca4acea3bddaec00@mail.gmail.com","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-11T14:15:47Z","receivedAt":"2008-08-11T14:15:47Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 11 Aug 2008, Francis Moreau wrote:\n\n> I found this in git bisect:\n> \n>               printf >&2 'Are you sure [Y/n]? '\n>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n> \n> which looks very weird since read(1) returns a status and not the\n> string reads from std input.\n> \n> Am I missing something ?\n\nYes.  \"$()\" does not return the status, but the output.\n\nCiao,\nDscho\n"},{"id":"86770","messageId":"237967ef0808110716l2a0a2a4je22c2a1b8c239f57@mail.gmail.com","threadId":"14930","inReplyTo":"alpine.DEB.1.00.0808111615260.24820@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Mikael Magnusson","fromEmail":"mikachu@gmail.com","sentAt":"2008-08-11T14:16:50Z","receivedAt":"2008-08-11T14:16:50Z","isPatch":false,"sender":{"key":"mikachu@gmail.com","avatar":null},"body":"2008/8/11 Johannes Schindelin <Johannes.Schindelin@gmx.de>:\n> Hi,\n>\n> On Mon, 11 Aug 2008, Francis Moreau wrote:\n>\n>> I found this in git bisect:\n>>\n>>               printf >&2 'Are you sure [Y/n]? '\n>>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n>>\n>> which looks very weird since read(1) returns a status and not the\n>> string reads from std input.\n>>\n>> Am I missing something ?\n>\n> Yes.  \"$()\" does not return the status, but the output.\n\nBut there is no output, since read doesn't print anything...\ncase \"$(read yesno; echo $yesno)\" in [Nn]*) could work, but looks\na bit strange. read yesno; case $yesno in [Nn]*) would be the usual\nway to do things i think?\n\n-- \nMikael Magnusson\n"},{"id":"86771","messageId":"38b2ab8a0808110718x2f63608ga3d2d77e317ce4eb@mail.gmail.com","threadId":"14930","inReplyTo":"alpine.DEB.1.00.0808111615260.24820@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2008-08-11T14:18:40Z","receivedAt":"2008-08-11T14:18:40Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"Hello\n\nOn Mon, Aug 11, 2008 at 4:15 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n> On Mon, 11 Aug 2008, Francis Moreau wrote:\n>\n>> I found this in git bisect:\n>>\n>>               printf >&2 'Are you sure [Y/n]? '\n>>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n>>\n>> which looks very weird since read(1) returns a status and not the\n>> string reads from std input.\n>>\n\nsorry I should have said that there's a status but no output...\n\n>> Am I missing something ?\n>\n> Yes.  \"$()\" does not return the status, but the output.\n>\n\nBut what's the output in that case ?\n\n-- \nFrancis\n"},{"id":"86786","messageId":"3f4fd2640808110859r148550d2h833dae05b9e6544e@mail.gmail.com","threadId":"14930","inReplyTo":"38b2ab8a0808110718x2f63608ga3d2d77e317ce4eb@mail.gmail.com","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Reece Dunn","fromEmail":"msclrhd@googlemail.com","sentAt":"2008-08-11T15:59:32Z","receivedAt":"2008-08-11T15:59:32Z","isPatch":false,"sender":{"key":"msclrhd@googlemail.com","avatar":null},"body":"2008/8/11 Francis Moreau <francis.moro@gmail.com>:\n> Hello\n>\n> On Mon, Aug 11, 2008 at 4:15 PM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n>> Hi,\n>>\n>> On Mon, 11 Aug 2008, Francis Moreau wrote:\n>>\n>>> I found this in git bisect:\n>>>\n>>>               printf >&2 'Are you sure [Y/n]? '\n>>>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n>>>\n>>> which looks very weird since read(1) returns a status and not the\n>>> string reads from std input.\n>>>\n>\n> sorry I should have said that there's a status but no output...\n>\n>>> Am I missing something ?\n>>\n>> Yes.  \"$()\" does not return the status, but the output.\n>>\n>\n> But what's the output in that case ?\n\nUsing cygwin+bash, I get:\n\n$ echo $(read yesno)\nn\n\n$ echo $(read yesno; echo $yesno)\nn\nn\n$ $(read yesno) && echo yes || echo no\nn\nyes\n$ $(read yesno) && echo yes || echo no\ny\nyes\n$ case \"$(read yesno)\" in [Nn]*) echo \"no\" ;; esac\nn\n$ case \"$(read yesno)\" in [Nn]*) echo \"no\" ;; esac\ny\n$ case \"$(read yesno; echo $yesno)\" in [Nn]*) echo \"no\" ;; esac\nn\nno\n$ case \"$(read yesno; echo $yesno)\" in [Nn]*) echo \"no\" ;; esac\ny\n\nSo\n\n>>>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n\ndoes not work as expected. Replacing this with\n\n               case \"$(read yesno; echo $yesno)\" in [Nn]*) exit 1 ;; esac\n\nwould work as intended, as Mikael has pointed out.\n\n- Reece\n"},{"id":"86788","messageId":"48A06659.6010004@lsrfire.ath.cx","threadId":"14930","inReplyTo":"38b2ab8a0808110657y24ac9526wca4acea3bddaec00@mail.gmail.com","subject":"Re: git-bisect: weird usage of read(1)","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-08-11T16:18:33Z","receivedAt":"2008-08-11T16:18:33Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Francis Moreau schrieb:\n> I found this in git bisect:\n> \n>               printf >&2 'Are you sure [Y/n]? '\n>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n> \n> which looks very weird since read(1) returns a status and not the\n> string reads from std input.\n\nGood catch.  You need to press Ctrl-C in order to exit, answering \"no\"\nmeans the same as \"yes\" here -- not very nice.  Care to send a patch?\n\nThanks,\nRené\n"},{"id":"86789","messageId":"38b2ab8a0808110923u21d543f0qbc9dee0f99c97311@mail.gmail.com","threadId":"14930","inReplyTo":"3f4fd2640808110859r148550d2h833dae05b9e6544e@mail.gmail.com","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2008-08-11T16:23:19Z","receivedAt":"2008-08-11T16:23:19Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"On Mon, Aug 11, 2008 at 5:59 PM, Reece Dunn <msclrhd@googlemail.com> wrote:\n> $ $(read yesno) && echo yes || echo no\n> n\n> yes\n> $ $(read yesno) && echo yes || echo no\n> y\n> yes\n\nfunny, seeing these 2 cases I'm wondering why Bash is not complaining...\n\n-- \nFrancis\n"},{"id":"86790","messageId":"3f4fd2640808110926w13104a08l687c8accc29e332@mail.gmail.com","threadId":"14930","inReplyTo":"38b2ab8a0808110923u21d543f0qbc9dee0f99c97311@mail.gmail.com","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Reece Dunn","fromEmail":"msclrhd@googlemail.com","sentAt":"2008-08-11T16:26:04Z","receivedAt":"2008-08-11T16:26:04Z","isPatch":false,"sender":{"key":"msclrhd@googlemail.com","avatar":null},"body":"2008/8/11 Francis Moreau <francis.moro@gmail.com>:\n> On Mon, Aug 11, 2008 at 5:59 PM, Reece Dunn <msclrhd@googlemail.com> wrote:\n>> $ $(read yesno) && echo yes || echo no\n>> n\n>> yes\n>> $ $(read yesno) && echo yes || echo no\n>> y\n>> yes\n>\n> funny, seeing these 2 cases I'm wondering why Bash is not complaining...\n\nI don't know; it could be an issue with cygwin.\n\nI'll try it on a Linux box later and post the results then for comparison.\n\n- Reece\n"},{"id":"86791","messageId":"38b2ab8a0808110929i47f7e4dt5287d149d10afbaf@mail.gmail.com","threadId":"14930","inReplyTo":"3f4fd2640808110926w13104a08l687c8accc29e332@mail.gmail.com","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2008-08-11T16:29:51Z","receivedAt":"2008-08-11T16:29:51Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"On Mon, Aug 11, 2008 at 6:26 PM, Reece Dunn <msclrhd@googlemail.com> wrote:\n> 2008/8/11 Francis Moreau <francis.moro@gmail.com>:\n>> On Mon, Aug 11, 2008 at 5:59 PM, Reece Dunn <msclrhd@googlemail.com> wrote:\n>>> $ $(read yesno) && echo yes || echo no\n>>> n\n>>> yes\n>>> $ $(read yesno) && echo yes || echo no\n>>> y\n>>> yes\n>>\n>> funny, seeing these 2 cases I'm wondering why Bash is not complaining...\n>\n> I don't know; it could be an issue with cygwin.\n>\n> I'll try it on a Linux box later and post the results then for comparison.\n>\n\nI got the same result on Linux...\n\n-- \nFrancis\n"},{"id":"86794","messageId":"20080811164945.GI32184@machine.or.cz","threadId":"14930","inReplyTo":"3f4fd2640808110859r148550d2h833dae05b9e6544e@mail.gmail.com","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-08-11T16:49:45Z","receivedAt":"2008-08-11T16:49:45Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"On Mon, Aug 11, 2008 at 04:59:32PM +0100, Reece Dunn wrote:\n> >> On Mon, 11 Aug 2008, Francis Moreau wrote:\n> >>>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n> \n> does not work as expected. Replacing this with\n> \n>                case \"$(read yesno; echo $yesno)\" in [Nn]*) exit 1 ;; esac\n> \n> would work as intended, as Mikael has pointed out.\n\n  Wouldn't it be more elegant to\n\n\tcase \"$(head -n 1)\" in [Nn]*) exit 1 ;; esac\n\n\t\t\t\tPetr \"Pasky\" Baudis\n"},{"id":"86795","messageId":"48A0705B.3030107@lsrfire.ath.cx","threadId":"14930","inReplyTo":"20080811164945.GI32184@machine.or.cz","subject":"Re: git-bisect: weird usage of read(1)","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-08-11T17:01:15Z","receivedAt":"2008-08-11T17:01:15Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Petr Baudis schrieb:\n> On Mon, Aug 11, 2008 at 04:59:32PM +0100, Reece Dunn wrote:\n>>>> On Mon, 11 Aug 2008, Francis Moreau wrote:\n>>>>>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n>> does not work as expected. Replacing this with\n>>\n>>                case \"$(read yesno; echo $yesno)\" in [Nn]*) exit 1 ;; esac\n>>\n>> would work as intended, as Mikael has pointed out.\n> \n>   Wouldn't it be more elegant to\n> \n> \tcase \"$(head -n 1)\" in [Nn]*) exit 1 ;; esac\n\nOnly if head is a built-in, otherwise you fork needlessly.  Not that\nthis is a performance critical part, but I wouldn't call it \"elegant\".\n\nWhat's wrong with the following variant, already used a few lines up in\nthe file?\n\n\tread yesno\n\tcase \"$yesno\" in [Nn]*) exit 1 ;; esac\n\nRené\n"},{"id":"86796","messageId":"20080811170515.GD10151@machine.or.cz","threadId":"14930","inReplyTo":"48A0705B.3030107@lsrfire.ath.cx","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-08-11T17:05:15Z","receivedAt":"2008-08-11T17:05:15Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"On Mon, Aug 11, 2008 at 07:01:15PM +0200, René Scharfe wrote:\n> Petr Baudis schrieb:\n> > On Mon, Aug 11, 2008 at 04:59:32PM +0100, Reece Dunn wrote:\n> >>>> On Mon, 11 Aug 2008, Francis Moreau wrote:\n> >>>>>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n> >> does not work as expected. Replacing this with\n> >>\n> >>                case \"$(read yesno; echo $yesno)\" in [Nn]*) exit 1 ;; esac\n> >>\n> >> would work as intended, as Mikael has pointed out.\n> > \n> >   Wouldn't it be more elegant to\n> > \n> > \tcase \"$(head -n 1)\" in [Nn]*) exit 1 ;; esac\n> \n> Only if head is a built-in, otherwise you fork needlessly.  Not that\n> this is a performance critical part, but I wouldn't call it \"elegant\".\n\nOk, exec head -n 1. ;) And yes, I know... I guess I've just spent too\nmuch time perl-golfing lately.\n\n> What's wrong with the following variant, already used a few lines up in\n> the file?\n> \n> \tread yesno\n> \tcase \"$yesno\" in [Nn]*) exit 1 ;; esac\n\nNothing wrong with this one, of course.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nThe next generation of interesting software will be done\non the Macintosh, not the IBM PC.  -- Bill Gates\n"},{"id":"86798","messageId":"38b2ab8a0808111038q686c9581pb277ab6d2229afd@mail.gmail.com","threadId":"14930","inReplyTo":"48A06659.6010004@lsrfire.ath.cx","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2008-08-11T17:38:05Z","receivedAt":"2008-08-11T17:38:05Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"On Mon, Aug 11, 2008 at 6:18 PM, René Scharfe\n<rene.scharfe@lsrfire.ath.cx> wrote:\n> Francis Moreau schrieb:\n>> I found this in git bisect:\n>>\n>>               printf >&2 'Are you sure [Y/n]? '\n>>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n>>\n>> which looks very weird since read(1) returns a status and not the\n>> string reads from std input.\n>\n> Good catch.  You need to press Ctrl-C in order to exit, answering \"no\"\n> means the same as \"yes\" here -- not very nice.  Care to send a patch?\n>\n\ndone.\n\n-- \nFrancis\n"},{"id":"86807","messageId":"7v7ianxtqv.fsf@gitster.siamese.dyndns.org","threadId":"14930","inReplyTo":"48A0705B.3030107@lsrfire.ath.cx","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-11T18:59:52Z","receivedAt":"2008-08-11T18:59:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n\n> Petr Baudis schrieb:\n>> On Mon, Aug 11, 2008 at 04:59:32PM +0100, Reece Dunn wrote:\n>>>>> On Mon, 11 Aug 2008, Francis Moreau wrote:\n>>>>>>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n>>> does not work as expected. Replacing this with\n>>>\n>>>                case \"$(read yesno; echo $yesno)\" in [Nn]*) exit 1 ;; esac\n>>>\n>>> would work as intended, as Mikael has pointed out.\n>> \n>>   Wouldn't it be more elegant to\n>> \n>> \tcase \"$(head -n 1)\" in [Nn]*) exit 1 ;; esac\n>\n> Only if head is a built-in, otherwise you fork needlessly.  Not that\n> this is a performance critical part, but I wouldn't call it \"elegant\".\n>\n> What's wrong with the following variant, already used a few lines up in\n> the file?\n>\n> \tread yesno\n> \tcase \"$yesno\" in [Nn]*) exit 1 ;; esac\n\nThat's the right way to spell it.  Sorry, I must have been too tired\nwhen I did this.\n"},{"id":"86819","messageId":"38b2ab8a0808111247w4837a1bfn774b9c2e9b98d38b@mail.gmail.com","threadId":"14930","inReplyTo":"7v7ianxtqv.fsf@gitster.siamese.dyndns.org","subject":"Re: git-bisect: weird usage of read(1)","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2008-08-11T19:47:25Z","receivedAt":"2008-08-11T19:47:25Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"On Mon, Aug 11, 2008 at 8:59 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n>\n>> Petr Baudis schrieb:\n>>> On Mon, Aug 11, 2008 at 04:59:32PM +0100, Reece Dunn wrote:\n>>>>>> On Mon, 11 Aug 2008, Francis Moreau wrote:\n>>>>>>>               case \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\n>>>> does not work as expected. Replacing this with\n>>>>\n>>>>                case \"$(read yesno; echo $yesno)\" in [Nn]*) exit 1 ;; esac\n>>>>\n>>>> would work as intended, as Mikael has pointed out.\n>>>\n>>>   Wouldn't it be more elegant to\n>>>\n>>>      case \"$(head -n 1)\" in [Nn]*) exit 1 ;; esac\n>>\n>> Only if head is a built-in, otherwise you fork needlessly.  Not that\n>> this is a performance critical part, but I wouldn't call it \"elegant\".\n>>\n>> What's wrong with the following variant, already used a few lines up in\n>> the file?\n>>\n>>       read yesno\n>>       case \"$yesno\" in [Nn]*) exit 1 ;; esac\n>\n> That's the right way to spell it.  Sorry, I must have been too tired\n> when I did this.\n>\n>\n>\n\nI sent a patch to fix that way already\n\nCheers.\n-- \nFrancis\n"}]}