{"thread":{"id":"43509","subject":"Re: git-PS1 bash prompt setting","startedAt":"2006-11-17T08:38:02Z","lastAt":"2006-11-19T06:28:14Z","messageCount":4,"participants":["Nicolas Vilz","Junio C Hamano","Sean"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"295209","messageId":"20061117083801.GB11468@fry.bender.fht","threadId":"43509","inReplyTo":"20061116130111.921396df.seanlkml@sympatico.ca","subject":"Re: git-PS1 bash prompt setting","fromName":"Nicolas Vilz","fromEmail":"niv@iaglans.de","sentAt":"2006-11-17T08:38:02Z","receivedAt":"2006-11-17T08:38:02Z","isPatch":false,"sender":{"key":"niv@iaglans.de","avatar":"https://gravatar.com/avatar/e4d43a32d721241212d4edb1d2210327e28423c913071b4bfeeaa0ce15296110?d=mp&s=160"},"body":"On Thu, Nov 16, 2006 at 01:01:11PM -0500, Sean wrote:\n\n> [branch!repo/relative/path]$ \n> \n> Where \"repo\" is the basename of the path to the root of your repo.\n> An example would look like this:\n> \n> [master!linus-2.6/Documentation/vm]$ \n> \n> Cheers,\n> Sean\n> \n> \n> #!/bin/bash\n> BR=$(git symbolic-ref HEAD 2>/dev/null) || { echo \"$@\" ; exit ; }\n> BR=${BR#refs/heads/}\n> REL=$(git rev-parse --show-prefix) \n> REL=\"${REL//%\\/}\"\n> LOC=\"${PWD%/$REL}\"\n> echo \"[$BR!${LOC/*\\/}${REL:+/$REL}]$ \"\n\nJust a note:\n\nthis doesn't work with bash 3.2. I think they altered the way of\ntrimming variables in this version.\n\non systems with bash 3.2 installed, i get\n[master!linus-2.6/vm/vm]$ \nwith the example above.\n\non systems with bash 3.1, it works properly.\n\nunfortunatelly, i am not so good in bash scripting, so it will take some\ntime for me to fix it.\n\nSincerly\n"},{"id":"297527","messageId":"BAYC1-PASMTP0635A081EAC964E03599B4AEE80@CEZ.ICE","threadId":"43509","inReplyTo":"20061117083801.GB11468@fry.bender.fht","subject":"Re: git-PS1 bash prompt setting","fromName":"Sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2006-11-17T09:20:51Z","receivedAt":"2006-11-17T09:20:51Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Fri, 17 Nov 2006 09:38:02 +0100\nNicolas Vilz <niv@iaglans.de> wrote:\n\n> Just a note:\n> \n> this doesn't work with bash 3.2. I think they altered the way of\n> trimming variables in this version.\n> \n> on systems with bash 3.2 installed, i get\n> [master!linus-2.6/vm/vm]$ \n> with the example above.\n> \n> on systems with bash 3.1, it works properly.\n\nSorry bout that, I knew it was a bit fragile.  Was rather\ncomical reading Junio's recent message about all the things not\nto do if you want portable shell code and noticing my 6 line script\ndid 90% of them ;o)  Strange though, I downloaded Bash 3.2\nand gave it a try and didn't see the problem here..\n\nWanna try this small change, to see if it helps? :\n\n#!/bin/bash\nBR=$(git symbolic-ref HEAD 2>/dev/null) || { echo \"$@\" ; exit ; }\nBR=${BR#refs/heads/}\nREL=$(git rev-parse --show-prefix)\nREL=\"${REL%\\/}\"\nLOC=\"${PWD%/$REL}\"\necho \"[$BR!${LOC/*\\/}${REL:+/$REL}]$ \"\n"},{"id":"297438","messageId":"20061117095237.GD11468@fry.bender.fht","threadId":"43509","inReplyTo":"20061117042051.d2fbddb6.seanlkml@sympatico.ca","subject":"Re: git-PS1 bash prompt setting","fromName":"Nicolas Vilz","fromEmail":"niv@iaglans.de","sentAt":"2006-11-17T09:52:37Z","receivedAt":"2006-11-17T09:52:37Z","isPatch":false,"sender":{"key":"niv@iaglans.de","avatar":"https://gravatar.com/avatar/e4d43a32d721241212d4edb1d2210327e28423c913071b4bfeeaa0ce15296110?d=mp&s=160"},"body":"On Fri, Nov 17, 2006 at 04:20:51AM -0500, Sean wrote:\n> On Fri, 17 Nov 2006 09:38:02 +0100\n> Nicolas Vilz <niv@iaglans.de> wrote:\n> \n> > Just a note:\n> > \n> > this doesn't work with bash 3.2. I think they altered the way of\n> > trimming variables in this version.\n> > \n> > on systems with bash 3.2 installed, i get\n> > [master!linus-2.6/vm/vm]$ \n> > with the example above.\n> > \n> > on systems with bash 3.1, it works properly.\n> \n> Sorry bout that, I knew it was a bit fragile.  Was rather\n> comical reading Junio's recent message about all the things not\n> to do if you want portable shell code and noticing my 6 line script\n> did 90% of them ;o)  Strange though, I downloaded Bash 3.2\n> and gave it a try and didn't see the problem here..\n> \n> Wanna try this small change, to see if it helps? :\n> \n> #!/bin/bash\n> BR=$(git symbolic-ref HEAD 2>/dev/null) || { echo \"$@\" ; exit ; }\n> BR=${BR#refs/heads/}\n> REL=$(git rev-parse --show-prefix)\n> REL=\"${REL%\\/}\"\n> LOC=\"${PWD%/$REL}\"\n> echo \"[$BR!${LOC/*\\/}${REL:+/$REL}]$ \"\n> \n\nThat one did the job... funny, removing these two // did the job, for\nboth versions, \nGNU bash, version 3.1.17(1)-release (powerpc-unknown-linux-gnu) and\nGNU bash, version 3.2.5(1)-release (x86_64-pc-linux-gnu).\n\nThx for fixing that script. It really helps me.\n\nSincerly\nNicolas\n"},{"id":"296382","messageId":"7vhcww7xxd.fsf@assigned-by-dhcp.cox.net","threadId":"43509","inReplyTo":"BAYC1-PASMTP0635A081EAC964E03599B4AEE80@CEZ.ICE","subject":"Re: git-PS1 bash prompt setting","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-19T06:28:14Z","receivedAt":"2006-11-19T06:28:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sean <seanlkml@sympatico.ca> writes:\n\n> On Fri, 17 Nov 2006 09:38:02 +0100\n> Nicolas Vilz <niv@iaglans.de> wrote:\n>\n>> Just a note:\n>> \n>> this doesn't work with bash 3.2. I think they altered the way of\n>> trimming variables in this version.\n>> \n>> on systems with bash 3.2 installed, i get\n>> [master!linus-2.6/vm/vm]$ \n>> with the example above.\n>> \n>> on systems with bash 3.1, it works properly.\n>\n> Sorry bout that, I knew it was a bit fragile.  Was rather\n> comical reading Junio's recent message about all the things not\n> to do if you want portable shell code and noticing my 6 line script\n> did 90% of them ;o)\n\nMaybe I should have been more explicit when I said \"${paremeter##word}\nand friends\".  Might not have been obvious, but I only meant the\nfollowing four: %, %%, # and ##.\n\n${parameter/pattern/string} and ${parameter//pattern/string} are\nnot even in POSIX.\n\n"}]}