{"thread":{"id":"30245","subject":"[PATCH v3 0/5] completion: trivial cleanups and fixes","startedAt":"2012-04-14T21:42:59Z","lastAt":"2012-04-15T19:42:56Z","messageCount":15,"participants":["Felipe Contreras","Thomas Rast","Andreas Schwab","SZEDER Gábor","Jonathan Nieder"],"isPatch":true,"patchVersion":3,"patchTotal":5},"messages":[{"id":"189288","messageId":"1334439784-6460-1-git-send-email-felipe.contreras@gmail.com","threadId":"30245","inReplyTo":null,"subject":"[PATCH v3 0/5] completion: trivial cleanups and fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-14T21:42:59Z","receivedAt":"2012-04-14T21:42:59Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nJust a few simpliciations, improvements, and add some missing options.\n\nThis series depends on the bash completion tests patch.\n\nSince v2:\n\n * Add 'git --option <TAB>' fix\n * Improve --exec-path patch\n\nFelipe Contreras (3):\n  completion: simplify __gitcomp_1\n  completion: trivial simplification\n  completion: add missing general options\n\nJonathan Nieder (1):\n  completion: avoid trailing space for --exec-path\n\nSZEDER Gábor (1):\n  completion: fix completion after 'git --option <TAB>'\n\n contrib/completion/git-completion.bash |   18 +++++++++------\n t/t9902-completion.sh                  |   38 ++++++++++++++++++++++++++++++++\n 2 files changed, 49 insertions(+), 7 deletions(-)\n\n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189289","messageId":"1334439784-6460-2-git-send-email-felipe.contreras@gmail.com","threadId":"30245","inReplyTo":"1334439784-6460-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v3 1/5] completion: simplify __gitcomp_1","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-14T21:43:00Z","receivedAt":"2012-04-14T21:43:00Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |    8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 31f714d..13be9a7 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -307,13 +307,13 @@ __git_ps1 ()\n # __gitcomp_1 requires 2 arguments\n __gitcomp_1 ()\n {\n-\tlocal c IFS=' '$'\\t'$'\\n'\n+\tlocal c s IFS=' '$'\\t'$'\\n'\n \tfor c in $1; do\n \t\tcase \"$c$2\" in\n-\t\t--*=*) printf %s$'\\n' \"$c$2\" ;;\n-\t\t*.)    printf %s$'\\n' \"$c$2\" ;;\n-\t\t*)     printf %s$'\\n' \"$c$2 \" ;;\n+\t\t--*=* | *.) s=\"\" ;;\n+\t\t*)          s=\" \" ;;\n \t\tesac\n+\t\techo \"$c$2$s\"\n \tdone\n }\n \n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189290","messageId":"1334439784-6460-3-git-send-email-felipe.contreras@gmail.com","threadId":"30245","inReplyTo":"1334439784-6460-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v3 2/5] completion: trivial simplification","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-14T21:43:01Z","receivedAt":"2012-04-14T21:43:01Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"cword-1 is the previous word ($prev).\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |    4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 13be9a7..9d36bb7 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1658,7 +1658,7 @@ _git_notes ()\n \t\t__gitcomp '--ref'\n \t\t;;\n \t,*)\n-\t\tcase \"${words[cword-1]}\" in\n+\t\tcase \"$prev\" in\n \t\t--ref)\n \t\t\t__gitcomp_nl \"$(__git_refs)\"\n \t\t\t;;\n@@ -1684,7 +1684,7 @@ _git_notes ()\n \tprune,*)\n \t\t;;\n \t*)\n-\t\tcase \"${words[cword-1]}\" in\n+\t\tcase \"$prev\" in\n \t\t-m|-F)\n \t\t\t;;\n \t\t*)\n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189291","messageId":"1334439784-6460-4-git-send-email-felipe.contreras@gmail.com","threadId":"30245","inReplyTo":"1334439784-6460-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v3 3/5] completion: add missing general options","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-14T21:43:02Z","receivedAt":"2012-04-14T21:43:02Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"And add relevant tests.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |    2 ++\n t/t9902-completion.sh                  |   16 ++++++++++++++++\n 2 files changed, 18 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9d36bb7..6a8cf9f 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2640,8 +2640,10 @@ _git ()\n \t\t\t--version\n \t\t\t--exec-path\n \t\t\t--html-path\n+\t\t\t--info-path\n \t\t\t--work-tree=\n \t\t\t--namespace=\n+\t\t\t--no-replace-objects\n \t\t\t--help\n \t\t\t\"\n \t\t\t;;\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 7bd37f5..f24c968 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -95,8 +95,10 @@ test_expect_success 'double dash \"git\" itself' '\n \t--version Z\n \t--exec-path Z\n \t--html-path Z\n+\t--info-path Z\n \t--work-tree=\n \t--namespace=\n+\t--no-replace-objects Z\n \t--help Z\n \tEOF\n \ttest_completion \"git --\"\n@@ -117,4 +119,18 @@ test_expect_success 'double dash \"git checkout\"' '\n \ttest_completion \"git checkout --\"\n '\n \n+test_expect_success 'general options' '\n+\ttest_completion \"git --ver\" \"--version \" &&\n+\ttest_completion \"git --hel\" \"--help \" &&\n+\ttest_completion \"git --exe\" \"--exec-path \" &&\n+\ttest_completion \"git --htm\" \"--html-path \" &&\n+\ttest_completion \"git --pag\" \"--paginate \" &&\n+\ttest_completion \"git --no-p\" \"--no-pager \" &&\n+\ttest_completion \"git --git\" \"--git-dir=\" &&\n+\ttest_completion \"git --wor\" \"--work-tree=\" &&\n+\ttest_completion \"git --nam\" \"--namespace=\" &&\n+\ttest_completion \"git --bar\" \"--bare \" &&\n+\ttest_completion \"git --inf\" \"--info-path \" &&\n+\ttest_completion \"git --no-r\" \"--no-replace-objects \"\n+'\n test_done\n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189292","messageId":"1334439784-6460-5-git-send-email-felipe.contreras@gmail.com","threadId":"30245","inReplyTo":"1334439784-6460-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v3 4/5] completion: avoid trailing space for --exec-path","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-14T21:43:03Z","receivedAt":"2012-04-14T21:43:03Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\n--exec-path looks to the completion script like an unambiguous\nsuccessful completion, but it is wrong; the user could be trying to\ndo\n\n\tgit --exec-path; # print name of helper directory\n\nor\n\n\tgit --exec-path=/path/to/alternative/helper/dir <subcommand>\n\nso the most helpful thing to do is to leave out the trailing space and\nleave it to the operator to type an equal sign or carriage return\naccording to the situation.\n\nCc: Andreas Schwab <schwab@linux-m68k.org>\nReported-by: Felipe Contreras <felipe.contreras@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n[added tests]\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |    1 +\n t/t9902-completion.sh                  |    7 ++++++-\n 2 files changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6a8cf9f..647ee77 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2639,6 +2639,7 @@ _git ()\n \t\t\t--bare\n \t\t\t--version\n \t\t\t--exec-path\n+\t\t\t--exec-path=\n \t\t\t--html-path\n \t\t\t--info-path\n \t\t\t--work-tree=\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex f24c968..dfef809 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -94,6 +94,7 @@ test_expect_success 'double dash \"git\" itself' '\n \t--bare Z\n \t--version Z\n \t--exec-path Z\n+\t--exec-path=\n \t--html-path Z\n \t--info-path Z\n \t--work-tree=\n@@ -122,7 +123,11 @@ test_expect_success 'double dash \"git checkout\"' '\n test_expect_success 'general options' '\n \ttest_completion \"git --ver\" \"--version \" &&\n \ttest_completion \"git --hel\" \"--help \" &&\n-\ttest_completion \"git --exe\" \"--exec-path \" &&\n+\tsed -e \"s/Z$//\" >expected <<-\\EOF &&\n+\t--exec-path Z\n+\t--exec-path=\n+\tEOF\n+\ttest_completion \"git --exe\" &&\n \ttest_completion \"git --htm\" \"--html-path \" &&\n \ttest_completion \"git --pag\" \"--paginate \" &&\n \ttest_completion \"git --no-p\" \"--no-pager \" &&\n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189293","messageId":"1334439784-6460-6-git-send-email-felipe.contreras@gmail.com","threadId":"30245","inReplyTo":"1334439784-6460-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v3 5/5] completion: fix completion after 'git --option <TAB>'","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-14T21:43:04Z","receivedAt":"2012-04-14T21:43:04Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"From: SZEDER Gábor <szeder@ira.uka.de>\n\nGit's bash completion currently doesn't work when certain git options\nare specified, e.g. 'git --no-pager <TAB>' errors out with \"error:\ninvalid key: alias.--no-pager\".\n\nThe main _git() completion function finds out the git command name by\nlooping through all the words on the command line and searching for\nthe first word that is not a known option for the git command.\nUnfortunately the list of known git options was not updated in a long\ntime, and newer options are not skipped but mistaken for a git\ncommand.  Such a misrecognized \"command\" is then passed to\n__git_aliased_command(), which in turn passes it to a 'git config'\nquery, hence the error.\n\nCurrently the following options are misrecognized for a git command:\n\n  -c --no-pager --exec-path --html-path --man-path --info-path\n  --no-replace-objects --work-tree= --namespace=\n\nTo fix this we could just update the list of options to be skipped,\nbut the same issue will likely arise, if the git command learns a new\noption in the future.  Therefore, to make it more future proof against\nnew options, this patch changes that loop to skip all option-looking\nwords, i.e. words starting with a dash.\n\nWe also have to handle the '-c' option specially, because it takes a\nconfigutation parameter in a separate word, which must be skipped,\ntoo.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n[added tests]\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |    3 ++-\n t/t9902-completion.sh                  |   17 +++++++++++++++++\n 2 files changed, 19 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 647ee77..192e444 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2623,8 +2623,9 @@ _git ()\n \t\tcase \"$i\" in\n \t\t--git-dir=*) __git_dir=\"${i#--git-dir=}\" ;;\n \t\t--bare)      __git_dir=\".\" ;;\n-\t\t--version|-p|--paginate) ;;\n \t\t--help) command=\"help\"; break ;;\n+\t\t-c) c=$((++c)) ;;\n+\t\t-*) ;;\n \t\t*) command=\"$i\"; break ;;\n \t\tesac\n \t\t((c++))\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex dfef809..ab72378 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -138,4 +138,21 @@ test_expect_success 'general options' '\n \ttest_completion \"git --inf\" \"--info-path \" &&\n \ttest_completion \"git --no-r\" \"--no-replace-objects \"\n '\n+\n+test_expect_success 'general options plus command' '\n+\ttest_completion \"git --version check\" \"checkout \" &&\n+\ttest_completion \"git --paginate check\" \"checkout \" &&\n+\ttest_completion \"git --git-dir=foo check\" \"checkout \" &&\n+\ttest_completion \"git --bare check\" \"checkout \" &&\n+\ttest_completion \"git --help des\" \"describe \" &&\n+\ttest_completion \"git --exec-path=foo check\" \"checkout \" &&\n+\ttest_completion \"git --html-path check\" \"checkout \" &&\n+\ttest_completion \"git --no-pager check\" \"checkout \" &&\n+\ttest_completion \"git --work-tree=foo check\" \"checkout \" &&\n+\ttest_completion \"git --namespace=foo check\" \"checkout \" &&\n+\ttest_completion \"git --paginate check\" \"checkout \" &&\n+\ttest_completion \"git --info-path check\" \"checkout \" &&\n+\ttest_completion \"git --no-replace-objects check\" \"checkout \"\n+'\n+\n test_done\n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189297","messageId":"87obqueyas.fsf@thomas.inf.ethz.ch","threadId":"30245","inReplyTo":"1334439784-6460-2-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v3 1/5] completion: simplify __gitcomp_1","fromName":"Thomas Rast","fromEmail":"trast@inf.ethz.ch","sentAt":"2012-04-14T22:36:11Z","receivedAt":"2012-04-14T22:36:11Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n>  # __gitcomp_1 requires 2 arguments\n>  __gitcomp_1 ()\n>  {\n> -\tlocal c IFS=' '$'\\t'$'\\n'\n> +\tlocal c s IFS=' '$'\\t'$'\\n'\n>  \tfor c in $1; do\n>  \t\tcase \"$c$2\" in\n> -\t\t--*=*) printf %s$'\\n' \"$c$2\" ;;\n> -\t\t*.)    printf %s$'\\n' \"$c$2\" ;;\n> -\t\t*)     printf %s$'\\n' \"$c$2 \" ;;\n> +\t\t--*=* | *.) s=\"\" ;;\n> +\t\t*)          s=\" \" ;;\n>  \t\tesac\n> +\t\techo \"$c$2$s\"\n>  \tdone\n>  }\n\nSorry for not noticing earlier, but...\n\nI did a double take at the change to 'echo'.  I'm guessing from the\npatch that $c$2$s is never just '-e' or some other option taken by the\nbash version[1] of echo.  But can you be sure?  Do you know off hand\nwhether '-nbogus' complains, treats the -n as usual and prints 'bogus',\nor echoes '-nbogus'[2]?  Are you sure future bash versions won't break\nthis?\n\n\nAlso, I can't help but complain about your commit messages (again).\nCompare with Jonathan's in 4/5.  His patch is all of a one-line(!)\nchange\n\n \t\t\t--exec-path\n+\t\t\t--exec-path=\n\nyet his commit message is two paragraphs worth of explanations why the\nchanged behavior is more helpful than what we had before.\n\nOn the other hand, your commit message for the above says only\n\n  completion: simplify __gitcomp_1\n\nHowever, your patch is actually two different changes:\n\n1. the refactoring of the partial command: printf %s$'\\n' \"$c$2\n2. the change to echo\n\nThe latter is not in any way explained or justified by your (total\nabsence of a) commit message.\n\n\nFootnotes: \n[1]  POSIX states that echo \"shall not support any options\" and \"shall\nnot recognize the -- argument\", but we have printfs all over the code\nbase because option support is extremely inconsistent\n\n[2]  Spoiler: it prints -nbogus literally\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"189298","messageId":"CAMP44s3qXnONLh_=gO4_9DK2=bx0tLBTTAb4WenYh5k2QPQL-g@mail.gmail.com","threadId":"30245","inReplyTo":"87obqueyas.fsf@thomas.inf.ethz.ch","subject":"Re: [PATCH v3 1/5] completion: simplify __gitcomp_1","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-14T22:54:56Z","receivedAt":"2012-04-14T22:54:56Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Sun, Apr 15, 2012 at 1:36 AM, Thomas Rast <trast@inf.ethz.ch> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>>  # __gitcomp_1 requires 2 arguments\n>>  __gitcomp_1 ()\n>>  {\n>> -     local c IFS=' '$'\\t'$'\\n'\n>> +     local c s IFS=' '$'\\t'$'\\n'\n>>       for c in $1; do\n>>               case \"$c$2\" in\n>> -             --*=*) printf %s$'\\n' \"$c$2\" ;;\n>> -             *.)    printf %s$'\\n' \"$c$2\" ;;\n>> -             *)     printf %s$'\\n' \"$c$2 \" ;;\n>> +             --*=* | *.) s=\"\" ;;\n>> +             *)          s=\" \" ;;\n>>               esac\n>> +             echo \"$c$2$s\"\n>>       done\n>>  }\n>\n> Sorry for not noticing earlier, but...\n>\n> I did a double take at the change to 'echo'.  I'm guessing from the\n> patch that $c$2$s is never just '-e' or some other option taken by the\n> bash version[1] of echo.  But can you be sure?  Do you know off hand\n> whether '-nbogus' complains, treats the -n as usual and prints 'bogus',\n> or echoes '-nbogus'[2]?  Are you sure future bash versions won't break\n> this?\n\nThat doesn't make any sense to me. If you want that, you should do\n'eval \"echo $foo\"', and even if you do 'eval \"echo \\\"$foo\\\"\"', that\nwould be avoided.\n\n> Also, I can't help but complain about your commit messages (again).\n\nWell, we can start a discussion about how \"simplify __gitcomp_1\" does\nnot explain sufficiently that this is indeed a simplification of\n__gitcomp_1, but from previous experiences you don't really want to\ndiscuss, you just want to be right, and me to follow orders.\n\nPersonally, I don't see why every modified line needs an ode.\n\n> 1. the refactoring of the partial command: printf %s$'\\n' \"$c$2\n> 2. the change to echo\n\nOr\n\n1. simplifying __gitcomp_1\n\n> Footnotes:\n> [1]  POSIX states that echo \"shall not support any options\" and \"shall\n> not recognize the -- argument\", but we have printfs all over the code\n> base because option support is extremely inconsistent\n\nThis is a *bash* completion script.\n\nIf you *need* an essay for a commit message for a patch that\nessentially does nothing but simplify some code, I'll just drop it;\nit's not worth my effort.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189315","messageId":"CAMP44s05KsZFAW=i7TvN0jDNPyFZ4OHkOTwVp2+04CR-jsz-nA@mail.gmail.com","threadId":"30245","inReplyTo":"CAMP44s3qXnONLh_=gO4_9DK2=bx0tLBTTAb4WenYh5k2QPQL-g@mail.gmail.com","subject":"Re: [PATCH v3 1/5] completion: simplify __gitcomp_1","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-15T04:45:43Z","receivedAt":"2012-04-15T04:45:43Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Sun, Apr 15, 2012 at 1:54 AM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> On Sun, Apr 15, 2012 at 1:36 AM, Thomas Rast <trast@inf.ethz.ch> wrote:\n>> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>>\n>>>  # __gitcomp_1 requires 2 arguments\n>>>  __gitcomp_1 ()\n>>>  {\n>>> -     local c IFS=' '$'\\t'$'\\n'\n>>> +     local c s IFS=' '$'\\t'$'\\n'\n>>>       for c in $1; do\n>>>               case \"$c$2\" in\n>>> -             --*=*) printf %s$'\\n' \"$c$2\" ;;\n>>> -             *.)    printf %s$'\\n' \"$c$2\" ;;\n>>> -             *)     printf %s$'\\n' \"$c$2 \" ;;\n>>> +             --*=* | *.) s=\"\" ;;\n>>> +             *)          s=\" \" ;;\n>>>               esac\n>>> +             echo \"$c$2$s\"\n>>>       done\n>>>  }\n>>\n>> Sorry for not noticing earlier, but...\n>>\n>> I did a double take at the change to 'echo'.  I'm guessing from the\n>> patch that $c$2$s is never just '-e' or some other option taken by the\n>> bash version[1] of echo.  But can you be sure?  Do you know off hand\n>> whether '-nbogus' complains, treats the -n as usual and prints 'bogus',\n>> or echoes '-nbogus'[2]?  Are you sure future bash versions won't break\n>> this?\n>\n> That doesn't make any sense to me. If you want that, you should do\n> 'eval \"echo $foo\"', and even if you do 'eval \"echo \\\"$foo\\\"\"', that\n> would be avoided.\n\nActually, after a private discussion with Thomas, I realized that's on\nzsh, on bash it doesn't work as I expected, plus, in both 'echo \"-n\"'\ndoes the unexpected thing (to me).\n\nSo, it should be, maybe 'print \"%s\\n\" \"$c$2$s\"', or 'print \"%s$s\\n\" \"$c$2\"'.\n\nHowever, I would like to simplify it even more:\n\n__gitcomp_1 ()\n{\n\tlocal c w s IFS=' '$'\\t'$'\\n'\n\tfor c in $1; do\n\t\tw=\"$c$2\"\n\t\tcase \"$w\" in\n\t\t--*=*|*.) s=\"\" ;;\n\t\t*)        s=\" \" ;;\n\t\tesac\n\t\tprintf \"%s$s\\n\" \"$w\"\n\tdone\n}\n\n-- \nFelipe Contreras\n"},{"id":"189318","messageId":"m2ehrpcs9u.fsf@linux-m68k.org","threadId":"30245","inReplyTo":"CAMP44s05KsZFAW=i7TvN0jDNPyFZ4OHkOTwVp2+04CR-jsz-nA@mail.gmail.com","subject":"Re: [PATCH v3 1/5] completion: simplify __gitcomp_1","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-04-15T08:29:17Z","receivedAt":"2012-04-15T08:29:17Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> However, I would like to simplify it even more:\n>\n> __gitcomp_1 ()\n> {\n> \tlocal c w s IFS=' '$'\\t'$'\\n'\n> \tfor c in $1; do\n> \t\tw=\"$c$2\"\n> \t\tcase \"$w\" in\n> \t\t--*=*|*.) s=\"\" ;;\n> \t\t*)        s=\" \" ;;\n> \t\tesac\n> \t\tprintf \"%s$s\\n\" \"$w\"\n> \tdone\n> }\n\nOr even:\n\n__gitcomp_1 ()\n{\n\tlocal c IFS=$' \\t\\n'\n\tfor c in $1; do\n\t\tc=$c$2\n\t\tcase $c in\n\t\t--*=*|*.) ;;\n\t\t*)        c=\"$c \" ;;\n\t\tesac\n\t\tprintf '%s\\n' \"$c\"\n\tdone\n}\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"189320","messageId":"20120415093334.GB2900@goldbirke","threadId":"30245","inReplyTo":"m2ehrpcs9u.fsf@linux-m68k.org","subject":"Re: [PATCH v3 1/5] completion: simplify __gitcomp_1","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-15T09:33:34Z","receivedAt":"2012-04-15T09:33:34Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Sun, Apr 15, 2012 at 10:29:17AM +0200, Andreas Schwab wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n> \n> > However, I would like to simplify it even more:\n> >\n> > __gitcomp_1 ()\n> > {\n> > \tlocal c w s IFS=' '$'\\t'$'\\n'\n> > \tfor c in $1; do\n> > \t\tw=\"$c$2\"\n> > \t\tcase \"$w\" in\n> > \t\t--*=*|*.) s=\"\" ;;\n> > \t\t*)        s=\" \" ;;\n> > \t\tesac\n> > \t\tprintf \"%s$s\\n\" \"$w\"\n> > \tdone\n> > }\n> \n> Or even:\n> \n> __gitcomp_1 ()\n> {\n> \tlocal c IFS=$' \\t\\n'\n> \tfor c in $1; do\n> \t\tc=$c$2\n> \t\tcase $c in\n> \t\t--*=*|*.) ;;\n> \t\t*)        c=\"$c \" ;;\n> \t\tesac\n> \t\tprintf '%s\\n' \"$c\"\n> \tdone\n> }\n\nWe can even get rid of the %s with\n\n  printf -- \"$c\\n\"\n"},{"id":"189323","messageId":"m23985cokd.fsf@linux-m68k.org","threadId":"30245","inReplyTo":"20120415093334.GB2900@goldbirke","subject":"Re: [PATCH v3 1/5] completion: simplify __gitcomp_1","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-04-15T09:49:22Z","receivedAt":"2012-04-15T09:49:22Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"SZEDER Gábor <szeder@ira.uka.de> writes:\n\n> We can even get rid of the %s with\n>\n>   printf -- \"$c\\n\"\n\nOnly if $c can never contain special characters.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"189324","messageId":"20120415100903.GC2900@goldbirke","threadId":"30245","inReplyTo":"m23985cokd.fsf@linux-m68k.org","subject":"Re: [PATCH v3 1/5] completion: simplify __gitcomp_1","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-15T10:09:03Z","receivedAt":"2012-04-15T10:09:03Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Sun, Apr 15, 2012 at 11:49:22AM +0200, Andreas Schwab wrote:\n> SZEDER Gábor <szeder@ira.uka.de> writes:\n> \n> > We can even get rid of the %s with\n> >\n> >   printf -- \"$c\\n\"\n> \n> Only if $c can never contain special characters.\n\nThat's a good point, branch and tag names can contain '%', so the %s\nshall stay.\n"},{"id":"189338","messageId":"20120415132002.GB2544@burratino","threadId":"30245","inReplyTo":"1334439784-6460-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v3 0/5] completion: trivial cleanups and fixes","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-15T13:20:02Z","receivedAt":"2012-04-15T13:20:02Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> Just a few simpliciations, improvements, and add some missing options.\n\nI generally like this.  Quick comments:\n\n> Felipe Contreras (3):\n>   completion: simplify __gitcomp_1\n\nThomas and Gábor seem to have this one covered, with some improvements\nto it under discussion.\n\n>   completion: trivial simplification\n\nImproves consistency.  The changelog line isn't precise enough to\nremind me which change is being mentioned when reading it in the\nshortlog, so I guess I'd prefer something like\n\n\tcompletion: simplify by using $prev variable\n\n>   completion: add missing general options\n\nLikewise, a subject line like the following would work better for\nme.\n\n\tcompletion: --info-path and --no-replace-objects options for git\n\nHope that helps,\nJonathan\n"},{"id":"189346","messageId":"CAMP44s0EPgS8MX4B7Wc4XW+S+JeJiuo63Rv-KiP=q0YTMbtd7g@mail.gmail.com","threadId":"30245","inReplyTo":"20120415132002.GB2544@burratino","subject":"Re: [PATCH v3 0/5] completion: trivial cleanups and fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-15T19:42:56Z","receivedAt":"2012-04-15T19:42:56Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Sun, Apr 15, 2012 at 4:20 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n\n>>   completion: trivial simplification\n>\n> Improves consistency.  The changelog line isn't precise enough to\n> remind me which change is being mentioned when reading it in the\n> shortlog, so I guess I'd prefer something like\n>\n>        completion: simplify by using $prev variable\n\nOK.\n\n>>   completion: add missing general options\n>\n> Likewise, a subject line like the following would work better for\n> me.\n>\n>        completion: --info-path and --no-replace-objects options for git\n\nThat's too long, and I think it's less understandable: for git? Of\ncourse it's for git, for what else could it be? :) maybe s/options for\ngit/general options/, but it's still too long.\n\nI'll leave it like that, anybody else can change it if they wish.\n\nCheers.\n\n-- \nFelipe Contreras\n"}]}