{"thread":{"id":"31532","subject":"[PATCH/RFC] test-lib: add support for colors without tput","startedAt":"2012-09-14T16:41:45Z","lastAt":"2012-09-17T17:39:36Z","messageCount":17,"participants":["Erik Faye-Lund","Elia Pinto","Johannes Sixt","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"199041","messageId":"1347640905-1400-1-git-send-email-kusmabite@gmail.com","threadId":"31532","inReplyTo":null,"subject":"[PATCH/RFC] test-lib: add support for colors without tput","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-09-14T16:41:45Z","receivedAt":"2012-09-14T16:41:45Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"For platforms that does not have tput we can still perform coloring\nby manually emitting the ANSI control codes. If tput is missing from\n$PATH, install a replacement function.\n\nThe exact strings has been dumped from a machine that has tput, by\npiping the output of tput through 'od -c -An'.\n\nSigned-off-by: Erik Faye-Lund <kusmabite@gmail.com>\n---\n\nI got slightly annoyed that we didn't get colored output from the\ntests on Windows, so I decided to fix it.\n\nHopefully other platforms can benefit from this as well.\n\nI'm not super happy with the condition to enable it. I considered\nan environment variable as well, but decided against it because\n\"make -C t\" from the root does not seem to pick up environment\nvariables configured in the main Makefile.\n\nThoughts?\n\n t/test-lib.sh | 14 ++++++++++++++\n 1 file changed, 14 insertions(+)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 78c4286..7d1b34b 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -129,6 +129,20 @@ export _x05 _x40 _z40 LF\n # This test checks if command xyzzy does the right thing...\n # '\n # . ./test-lib.sh\n+\n+if ! which tput > /dev/null ; then\n+\ttput () {\n+\t\tcase \"$1\" in\n+\t\tbold)\n+\t\t\techo -ne \"\\033[1m\" ;;\n+\t\tsetaf)\n+\t\t\techo -ne \"\\033[0;3$2m\" ;;\n+\t\tsgr0)\n+\t\t\techo -ne \"\\033(\\033[m\" ;;\n+\t\tesac\n+\t}\n+fi\n+\n [ \"x$ORIGINAL_TERM\" != \"xdumb\" ] && (\n \t\tTERM=$ORIGINAL_TERM &&\n \t\texport TERM &&\n-- \n1.7.11.msysgit.0.5.g0225efe.dirty\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199044","messageId":"CABPQNSa1hEG_rB9hd8izW+iL1TQVAKu5W1=GbG20ROv-+DMgVg@mail.gmail.com","threadId":"31532","inReplyTo":"1347640905-1400-1-git-send-email-kusmabite@gmail.com","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-09-14T16:54:41Z","receivedAt":"2012-09-14T16:54:41Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Fri, Sep 14, 2012 at 6:41 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index 78c4286..7d1b34b 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -129,6 +129,20 @@ export _x05 _x40 _z40 LF\n>  # This test checks if command xyzzy does the right thing...\n>  # '\n>  # . ./test-lib.sh\n> +\n> +if ! which tput > /dev/null ; then\n> +       tput () {\n> +               case \"$1\" in\n> +               bold)\n> +                       echo -ne \"\\033[1m\" ;;\n> +               setaf)\n> +                       echo -ne \"\\033[0;3$2m\" ;;\n> +               sgr0)\n> +                       echo -ne \"\\033(\\033[m\" ;;\n\nI should of course have checked this earlier, but I find now that\n\"echo -ne\" isn't portable. So perhaps this on top?\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 7d1b34b..91a1d7b 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -134,11 +134,11 @@ if ! which tput > /dev/null ; then\n \ttput () {\n \t\tcase \"$1\" in\n \t\tbold)\n-\t\t\techo -ne \"\\033[1m\" ;;\n+\t\t\tprintf \"%b\" \"\\033[1m\" ;;\n \t\tsetaf)\n-\t\t\techo -ne \"\\033[0;3$2m\" ;;\n+\t\t\tprintf \"%b\" \"\\033[0;3$2m\" ;;\n \t\tsgr0)\n-\t\t\techo -ne \"\\033(\\033[m\" ;;\n+\t\t\tprintf \"%b\" \"\\033(\\033[m\" ;;\n \t\tesac\n \t}\n fi\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199045","messageId":"CABPQNSaArMz8hTiNZyD__K8bjntUuFUvk7Ojpu6NeXWLkJSUiA@mail.gmail.com","threadId":"31532","inReplyTo":"CABPQNSa1hEG_rB9hd8izW+iL1TQVAKu5W1=GbG20ROv-+DMgVg@mail.gmail.com","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-09-14T16:58:34Z","receivedAt":"2012-09-14T16:58:34Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Fri, Sep 14, 2012 at 6:54 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n> On Fri, Sep 14, 2012 at 6:41 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n>> diff --git a/t/test-lib.sh b/t/test-lib.sh\n>> index 78c4286..7d1b34b 100644\n>> --- a/t/test-lib.sh\n>> +++ b/t/test-lib.sh\n>> @@ -129,6 +129,20 @@ export _x05 _x40 _z40 LF\n>>  # This test checks if command xyzzy does the right thing...\n>>  # '\n>>  # . ./test-lib.sh\n>> +\n>> +if ! which tput > /dev/null ; then\n>> +       tput () {\n>> +               case \"$1\" in\n>> +               bold)\n>> +                       echo -ne \"\\033[1m\" ;;\n>> +               setaf)\n>> +                       echo -ne \"\\033[0;3$2m\" ;;\n>> +               sgr0)\n>> +                       echo -ne \"\\033(\\033[m\" ;;\n>\n> I should of course have checked this earlier, but I find now that\n> \"echo -ne\" isn't portable. So perhaps this on top?\n>\n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index 7d1b34b..91a1d7b 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -134,11 +134,11 @@ if ! which tput > /dev/null ; then\n>         tput () {\n>                 case \"$1\" in\n>                 bold)\n> -                       echo -ne \"\\033[1m\" ;;\n> +                       printf \"%b\" \"\\033[1m\" ;;\n>                 setaf)\n> -                       echo -ne \"\\033[0;3$2m\" ;;\n> +                       printf \"%b\" \"\\033[0;3$2m\" ;;\n>                 sgr0)\n> -                       echo -ne \"\\033(\\033[m\" ;;\n> +                       printf \"%b\" \"\\033(\\033[m\" ;;\n>                 esac\n>         }\n>  fi\n\nAnd again, I'm stupid for not reading documentation properly; octal\nescaped strings in the format string should work (and does on my\nsystems), so this is sufficient:\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 7d1b34b..2a6149e 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -134,11 +134,11 @@ if ! which tput > /dev/null ; then\n \ttput () {\n \t\tcase \"$1\" in\n \t\tbold)\n-\t\t\techo -ne \"\\033[1m\" ;;\n+\t\t\tprintf \"\\033[1m\" ;;\n \t\tsetaf)\n-\t\t\techo -ne \"\\033[0;3$2m\" ;;\n+\t\t\tprintf \"\\033[0;3$2m\" ;;\n \t\tsgr0)\n-\t\t\techo -ne \"\\033(\\033[m\" ;;\n+\t\t\tprintf \"\\033(\\033[m\" ;;\n \t\tesac\n \t}\n fi\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199046","messageId":"CA+EOSBm4cSu8cxPc-3Eqm0J7deeht6FMMUGBKP6vx8VDcVrGPQ@mail.gmail.com","threadId":"31532","inReplyTo":"CABPQNSaArMz8hTiNZyD__K8bjntUuFUvk7Ojpu6NeXWLkJSUiA@mail.gmail.com","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2012-09-14T17:08:00Z","receivedAt":"2012-09-14T17:08:00Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"2012/9/14 Erik Faye-Lund <kusmabite@gmail.com>:\n> On Fri, Sep 14, 2012 at 6:54 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n>> On Fri, Sep 14, 2012 at 6:41 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n>>> diff --git a/t/test-lib.sh b/t/test-lib.sh\n>>> index 78c4286..7d1b34b 100644\n>>> --- a/t/test-lib.sh\n>>> +++ b/t/test-lib.sh\n>>> @@ -129,6 +129,20 @@ export _x05 _x40 _z40 LF\n>>>  # This test checks if command xyzzy does the right thing...\n>>>  # '\n>>>  # . ./test-lib.sh\n>>> +\nNice. But this setting should be check that we have a terminal first isn't ?\nSome test like this before\n\ntest \"X$$TERM\" != Xdumb \\\n&&  test -t 1 2>/dev/null  \\\n&& ....\n\nor the inverse logic. This is what automake  and popt autogen.sh does.\n\nBest Regards\n"},{"id":"199049","messageId":"CABPQNSZSQCvoD=n-iQPSHbUQ2S4c0P1VTZfiHkRcwpm=7dk5Vg@mail.gmail.com","threadId":"31532","inReplyTo":"CA+EOSBm4cSu8cxPc-3Eqm0J7deeht6FMMUGBKP6vx8VDcVrGPQ@mail.gmail.com","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-09-14T17:11:34Z","receivedAt":"2012-09-14T17:11:34Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Fri, Sep 14, 2012 at 7:08 PM, Elia Pinto <gitter.spiros@gmail.com> wrote:\n> 2012/9/14 Erik Faye-Lund <kusmabite@gmail.com>:\n>> On Fri, Sep 14, 2012 at 6:54 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n>>> On Fri, Sep 14, 2012 at 6:41 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n>>>> diff --git a/t/test-lib.sh b/t/test-lib.sh\n>>>> index 78c4286..7d1b34b 100644\n>>>> --- a/t/test-lib.sh\n>>>> +++ b/t/test-lib.sh\n>>>> @@ -129,6 +129,20 @@ export _x05 _x40 _z40 LF\n>>>>  # This test checks if command xyzzy does the right thing...\n>>>>  # '\n>>>>  # . ./test-lib.sh\n>>>> +\n> Nice. But this setting should be check that we have a terminal first isn't ?\n> Some test like this before\n>\n> test \"X$$TERM\" != Xdumb \\\n> &&  test -t 1 2>/dev/null  \\\n> && ....\n>\n> or the inverse logic. This is what automake  and popt autogen.sh does.\n\nThere's already such a check a few lines further down, and tput isn't\nused in such cases.\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199050","messageId":"CA+EOSBki2syrwdfzFXzBPuJAhH2jfgAbL=W+yP7bx8WXMkYiMQ@mail.gmail.com","threadId":"31532","inReplyTo":"CA+EOSBm4cSu8cxPc-3Eqm0J7deeht6FMMUGBKP6vx8VDcVrGPQ@mail.gmail.com","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2012-09-14T17:12:20Z","receivedAt":"2012-09-14T17:12:20Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"2012/9/14 Elia Pinto <gitter.spiros@gmail.com>:\n> 2012/9/14 Erik Faye-Lund <kusmabite@gmail.com>:\n>> On Fri, Sep 14, 2012 at 6:54 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n>>> On Fri, Sep 14, 2012 at 6:41 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n>>>> diff --git a/t/test-lib.sh b/t/test-lib.sh\n>>>> index 78c4286..7d1b34b 100644\n>>>> --- a/t/test-lib.sh\n>>>> +++ b/t/test-lib.sh\n>>>> @@ -129,6 +129,20 @@ export _x05 _x40 _z40 LF\n>>>>  # This test checks if command xyzzy does the right thing...\n>>>>  # '\n>>>>  # . ./test-lib.sh\n>>>> +\n> Nice. But this setting should be check that we have a terminal first isn't ?\n> Some test like this before\n>\n> test \"X$$TERM\" != Xdumb \\\n> &&  test -t 1 2>/dev/null  \\\n> && ....\nand in reality this echo use is not portable.\nhttp://ftp.gnu.org/old-gnu/Manuals/autoconf-2.53/html_node/Limitations-of-Builtins.html\n\nIn popt 1_17 autogen.sh does\n\nred=; grn=; lgn=; blu=; std=;\ntest \"X$$TERM\" != Xdumb \\\n&&  test -t 1 2>/dev/null  \\\n&& { \\\n  red='^[[0;31m'; \\\n  grn='^[[0;32m'; \\\n  lgn='^[[1;32m'; \\\n  blu='^[[1;34m'; \\\n  std='^[[m'; \\\n}\n\nand\n\nDie()    {\n        color=\"$red\"\n        echo \"${color}${_PROGNAME}: Error: $@${std}\" >&2\n        exit 1\n}\n\nDie \"message here\"\n\n\n>\n> or the inverse logic. This is what automake  and popt autogen.sh does.\n>\n> Best Regards\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199051","messageId":"CABPQNSYu1mAxn_ZKqgM6xcsgJfegu=upv0QQpFryMVrEH+KAsw@mail.gmail.com","threadId":"31532","inReplyTo":"CA+EOSBki2syrwdfzFXzBPuJAhH2jfgAbL=W+yP7bx8WXMkYiMQ@mail.gmail.com","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-09-14T17:16:59Z","receivedAt":"2012-09-14T17:16:59Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Fri, Sep 14, 2012 at 7:12 PM, Elia Pinto <gitter.spiros@gmail.com> wrote:\n> 2012/9/14 Elia Pinto <gitter.spiros@gmail.com>:\n>> 2012/9/14 Erik Faye-Lund <kusmabite@gmail.com>:\n>>> On Fri, Sep 14, 2012 at 6:54 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n>>>> On Fri, Sep 14, 2012 at 6:41 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n>>>>> diff --git a/t/test-lib.sh b/t/test-lib.sh\n>>>>> index 78c4286..7d1b34b 100644\n>>>>> --- a/t/test-lib.sh\n>>>>> +++ b/t/test-lib.sh\n>>>>> @@ -129,6 +129,20 @@ export _x05 _x40 _z40 LF\n>>>>>  # This test checks if command xyzzy does the right thing...\n>>>>>  # '\n>>>>>  # . ./test-lib.sh\n>>>>> +\n>> Nice. But this setting should be check that we have a terminal first isn't ?\n>> Some test like this before\n>>\n>> test \"X$$TERM\" != Xdumb \\\n>> &&  test -t 1 2>/dev/null  \\\n>> && ....\n> and in reality this echo use is not portable.\n\nYeah; I posted a couple of follow-up mails earlier where I had noticed\nit and changed to printf instead. It seems the testsuite is already\nusing it, so it's probably portable.\n\nThanks a lot for the extra set of eyes :)\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199054","messageId":"50536943.4030300@kdbg.org","threadId":"31532","inReplyTo":"CABPQNSaArMz8hTiNZyD__K8bjntUuFUvk7Ojpu6NeXWLkJSUiA@mail.gmail.com","subject":"Re: Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-09-14T17:28:35Z","receivedAt":"2012-09-14T17:28:35Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 14.09.2012 18:58, schrieb Erik Faye-Lund:\n>  \ttput () {\n>  \t\tcase \"$1\" in\n>  \t\tbold)\n> -\t\t\techo -ne \"\\033[1m\" ;;\n> +\t\t\tprintf \"\\033[1m\" ;;\n>  \t\tsetaf)\n> -\t\t\techo -ne \"\\033[0;3$2m\" ;;\n> +\t\t\tprintf \"\\033[0;3$2m\" ;;\n\nThis should be\n\t\t\tprintf '\\033[0;3%sm' \"$2\" ;;\n\n>  \t\tsgr0)\n> -\t\t\techo -ne \"\\033(\\033[m\" ;;\n> +\t\t\tprintf \"\\033(\\033[m\" ;;\n>  \t\tesac\n>  \t}\n>  fi\n\nDid you test this only in rxvt or in CMD as well? (I hadn't time to\ntest, yet, so I'm asking :-)\n\n-- Hannes\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199055","messageId":"7va9ws5x6w.fsf@alter.siamese.dyndns.org","threadId":"31532","inReplyTo":"CABPQNSa1hEG_rB9hd8izW+iL1TQVAKu5W1=GbG20ROv-+DMgVg@mail.gmail.com","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-14T17:30:31Z","receivedAt":"2012-09-14T17:30:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Erik Faye-Lund <kusmabite@gmail.com> writes:\n\n> On Fri, Sep 14, 2012 at 6:41 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n>> diff --git a/t/test-lib.sh b/t/test-lib.sh\n>> index 78c4286..7d1b34b 100644\n>> --- a/t/test-lib.sh\n>> +++ b/t/test-lib.sh\n>> @@ -129,6 +129,20 @@ export _x05 _x40 _z40 LF\n>>  # This test checks if command xyzzy does the right thing...\n>>  # '\n>>  # . ./test-lib.sh\n>> +\n>> +if ! which tput > /dev/null ; then\n>> +       tput () {\n>> +               case \"$1\" in\n>> +               bold)\n>> +                       echo -ne \"\\033[1m\" ;;\n>> +               setaf)\n>> +                       echo -ne \"\\033[0;3$2m\" ;;\n>> +               sgr0)\n>> +                       echo -ne \"\\033(\\033[m\" ;;\n>\n> I should of course have checked this earlier, but I find now that\n> \"echo -ne\" isn't portable.\n\nNeither is which, no?\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199056","messageId":"CABPQNSbKWb-tWqFBtBCenJNDE6oVLyCbspoK+vLYj9yD6ZraWQ@mail.gmail.com","threadId":"31532","inReplyTo":"50536943.4030300@kdbg.org","subject":"Re: Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-09-14T17:31:00Z","receivedAt":"2012-09-14T17:31:00Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Fri, Sep 14, 2012 at 7:28 PM, Johannes Sixt <j6t@kdbg.org> wrote:\n> Am 14.09.2012 18:58, schrieb Erik Faye-Lund:\n>>       tput () {\n>>               case \"$1\" in\n>>               bold)\n>> -                     echo -ne \"\\033[1m\" ;;\n>> +                     printf \"\\033[1m\" ;;\n>>               setaf)\n>> -                     echo -ne \"\\033[0;3$2m\" ;;\n>> +                     printf \"\\033[0;3$2m\" ;;\n>\n> This should be\n>                         printf '\\033[0;3%sm' \"$2\" ;;\n>\n\nThat's probably a good idea, yeah.\n\n>>               sgr0)\n>> -                     echo -ne \"\\033(\\033[m\" ;;\n>> +                     printf \"\\033(\\033[m\" ;;\n>>               esac\n>>       }\n>>  fi\n>\n> Did you test this only in rxvt or in CMD as well? (I hadn't time to\n> test, yet, so I'm asking :-)\n\nI don't have rxvt installed, but it works for me in CMD also.\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199057","messageId":"CABPQNSb=j=TtZVm4tzR6HE+Fhh=Aa6GSnmaysLNBQTbtSie4Mg@mail.gmail.com","threadId":"31532","inReplyTo":"7va9ws5x6w.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-09-14T17:42:32Z","receivedAt":"2012-09-14T17:42:32Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Fri, Sep 14, 2012 at 7:30 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Erik Faye-Lund <kusmabite@gmail.com> writes:\n>\n>> On Fri, Sep 14, 2012 at 6:41 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote:\n>>> diff --git a/t/test-lib.sh b/t/test-lib.sh\n>>> index 78c4286..7d1b34b 100644\n>>> --- a/t/test-lib.sh\n>>> +++ b/t/test-lib.sh\n>>> @@ -129,6 +129,20 @@ export _x05 _x40 _z40 LF\n>>>  # This test checks if command xyzzy does the right thing...\n>>>  # '\n>>>  # . ./test-lib.sh\n>>> +\n>>> +if ! which tput > /dev/null ; then\n>>> +       tput () {\n>>> +               case \"$1\" in\n>>> +               bold)\n>>> +                       echo -ne \"\\033[1m\" ;;\n>>> +               setaf)\n>>> +                       echo -ne \"\\033[0;3$2m\" ;;\n>>> +               sgr0)\n>>> +                       echo -ne \"\\033(\\033[m\" ;;\n>>\n>> I should of course have checked this earlier, but I find now that\n>> \"echo -ne\" isn't portable.\n>\n> Neither is which, no?\n\nOooh, right. Thanks for noticing. So I guess I should try to run it\ninstead. From the POSIX spec, I can't find a way of running it that\nguarantees a return-code of 0 without clobbering the console somehow.\n\nPerhaps the best thing is pass no operands, and check for $? == 127 instead?\n\nSomething like this?\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex a939e19..1433cb3 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -130,7 +130,8 @@ export _x05 _x40 _z40 LF\n # '\n # . ./test-lib.sh\n\n-if ! which tput > /dev/null ; then\n+tput > /dev/null\n+if test $? -eq 127 ; then\n \ttput () {\n \t\tcase \"$1\" in\n \t\tbold)\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199058","messageId":"20120914174439.GA16657@sigill.intra.peff.net","threadId":"31532","inReplyTo":"1347640905-1400-1-git-send-email-kusmabite@gmail.com","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-09-14T17:44:39Z","receivedAt":"2012-09-14T17:44:39Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Sep 14, 2012 at 06:41:45PM +0200, Erik Faye-Lund wrote:\n\n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index 78c4286..7d1b34b 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -129,6 +129,20 @@ export _x05 _x40 _z40 LF\n>  # This test checks if command xyzzy does the right thing...\n>  # '\n>  # . ./test-lib.sh\n> +\n> +if ! which tput > /dev/null ; then\n\nTesting the return value of \"which\" is not portable (I know, it's\ninsane; SunOS is the common offender). Use \"type\" instead.\n\n-Peff\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199060","messageId":"CABPQNSYzSzMrmY4Jto+xig2BRL-P0xJDcUiBV8TtV3Ehd1DD_w@mail.gmail.com","threadId":"31532","inReplyTo":"20120914174439.GA16657@sigill.intra.peff.net","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-09-14T17:52:53Z","receivedAt":"2012-09-14T17:52:53Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Fri, Sep 14, 2012 at 7:44 PM, Jeff King <peff@peff.net> wrote:\n> On Fri, Sep 14, 2012 at 06:41:45PM +0200, Erik Faye-Lund wrote:\n>\n>> diff --git a/t/test-lib.sh b/t/test-lib.sh\n>> index 78c4286..7d1b34b 100644\n>> --- a/t/test-lib.sh\n>> +++ b/t/test-lib.sh\n>> @@ -129,6 +129,20 @@ export _x05 _x40 _z40 LF\n>>  # This test checks if command xyzzy does the right thing...\n>>  # '\n>>  # . ./test-lib.sh\n>> +\n>> +if ! which tput > /dev/null ; then\n>\n> Testing the return value of \"which\" is not portable (I know, it's\n> insane; SunOS is the common offender). Use \"type\" instead.\n\nJunio already noticed it, and I suggested a fix that involved running\nit. However, I like your fix much better, thanks :)\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199063","messageId":"7vpq5o4h30.fsf@alter.siamese.dyndns.org","threadId":"31532","inReplyTo":"CABPQNSb=j=TtZVm4tzR6HE+Fhh=Aa6GSnmaysLNBQTbtSie4Mg@mail.gmail.com","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-14T18:03:47Z","receivedAt":"2012-09-14T18:03:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Erik Faye-Lund <kusmabite@gmail.com> writes:\n\n>> Neither is which, no?\n>\n> Oooh, right. Thanks for noticing. So I guess I should try to run it\n> instead. From the  POSIX spec,...\n\nIf you assume POSIX.1, there is \"type\".\n\n    $ type frotz ; echo $?\n    frotz is /usr/games/frotz\n    0\n    $ type frobnitz ; echo $?\n    bash: type: frobnitz: not found\n    1\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199065","messageId":"CABPQNSZeuG-J8nVH15hpsX+bkM3CPcUGBNgNOUp6AtTipSdVbQ@mail.gmail.com","threadId":"31532","inReplyTo":"50536943.4030300@kdbg.org","subject":"Re: Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-09-14T18:11:48Z","receivedAt":"2012-09-14T18:11:48Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Fri, Sep 14, 2012 at 7:28 PM, Johannes Sixt <j6t@kdbg.org> wrote:\n> Am 14.09.2012 18:58, schrieb Erik Faye-Lund:\n>>       tput () {\n>>               case \"$1\" in\n>>               bold)\n>> -                     echo -ne \"\\033[1m\" ;;\n>> +                     printf \"\\033[1m\" ;;\n>>               setaf)\n>> -                     echo -ne \"\\033[0;3$2m\" ;;\n>> +                     printf \"\\033[0;3$2m\" ;;\n>\n> This should be\n>                         printf '\\033[0;3%sm' \"$2\" ;;\n\nIs there a reason for %s rather than %d? It seem it only takes\nintegers, and with %d at least we'd get an error message if someone\nstarted doing something else...\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199068","messageId":"50538261.8060102@kdbg.org","threadId":"31532","inReplyTo":"CABPQNSZeuG-J8nVH15hpsX+bkM3CPcUGBNgNOUp6AtTipSdVbQ@mail.gmail.com","subject":"Re: Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-09-14T19:15:45Z","receivedAt":"2012-09-14T19:15:45Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 14.09.2012 20:11, schrieb Erik Faye-Lund:\n> On Fri, Sep 14, 2012 at 7:28 PM, Johannes Sixt <j6t@kdbg.org> wrote:\n>>                         printf '\\033[0;3%sm' \"$2\" ;;\n> \n> Is there a reason for %s rather than %d? It seem it only takes\n> integers,..\n\nNo reason. I just mechanically converted your original expression. But\nthere is no reason for my conversion, either, if it can be more or less\nguaranteed that no arbitrary strings are passed in $2.\n\n-- Hannes\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"199260","messageId":"50576058.4020508@kdbg.org","threadId":"31532","inReplyTo":"50536943.4030300@kdbg.org","subject":"Re: [PATCH/RFC] test-lib: add support for colors without tput","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-09-17T17:39:36Z","receivedAt":"2012-09-17T17:39:36Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 14.09.2012 19:28, schrieb Johannes Sixt:\n> Am 14.09.2012 18:58, schrieb Erik Faye-Lund:\n>>  \ttput () {\n>>  \t\tcase \"$1\" in\n>>  \t\tbold)\n>> -\t\t\techo -ne \"\\033[1m\" ;;\n>> +\t\t\tprintf \"\\033[1m\" ;;\n>>  \t\tsetaf)\n>> -\t\t\techo -ne \"\\033[0;3$2m\" ;;\n>> +\t\t\tprintf \"\\033[0;3$2m\" ;;\n> \n> This should be\n> \t\t\tprintf '\\033[0;3%sm' \"$2\" ;;\n> \n>>  \t\tsgr0)\n>> -\t\t\techo -ne \"\\033(\\033[m\" ;;\n>> +\t\t\tprintf \"\\033(\\033[m\" ;;\n>>  \t\tesac\n>>  \t}\n>>  fi\n> \n> Did you test this only in rxvt or in CMD as well? (I hadn't time to\n> test, yet, so I'm asking :-)\n\nI tested your patch with this fixup, and it works for me (in CMD).\n\n-- Hannes\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"}]}