git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bash-completion] syntax error near unexpected token '<' on line 123 in bash_completion.d/git
@ 2010-07-25 11:12 solsTiCe d'Hiver
  2010-07-25 11:49 ` Ævar Arnfjörð Bjarmason
  2010-07-25 20:01 ` Andrew Sayers
  0 siblings, 2 replies; 7+ messages in thread
From: solsTiCe d'Hiver @ 2010-07-25 11:12 UTC (permalink / raw)
  To: git

hello,
I want to report a tiny "bug" (?) and I couldn't find a bug tracker so
here I am

When I boot my pc, I got an error on my console before gdm kick in to
launch gnome.

This is an error in /etc/bash_completion.d/git; it says
syntax error near unexpected token '<' on line 123

I use git 1.7.2 and bash 4.1.007 and the line 123
of /etc/bash_completion.d/git looks like this

	done < <(git config -z --get-regexp '^(svn-remote\..*\.url|bash
\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')

I think that may be there is too much < there.

but strangely if I source manually that file in a bash it works without
error.

originally reported there: http://bugs.archlinux.org/task/20264

P.S.: I have not subscribed to the ML.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [bash-completion] syntax error near unexpected token '<' on line  123 in bash_completion.d/git
  2010-07-25 11:12 [bash-completion] syntax error near unexpected token '<' on line 123 in bash_completion.d/git solsTiCe d'Hiver
@ 2010-07-25 11:49 ` Ævar Arnfjörð Bjarmason
  2010-07-25 20:01 ` Andrew Sayers
  1 sibling, 0 replies; 7+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-07-25 11:49 UTC (permalink / raw)
  To: solsTiCe d'Hiver; +Cc: git, Andrew Sayers

On Sun, Jul 25, 2010 at 11:12, solsTiCe d'Hiver
<solstice.dhiver@gmail.com> wrote:

>        done < <(git config -z --get-regexp '^(svn-remote\..*\.url|bash
> \.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')
>
> I think that may be there is too much < there.

That's not a syntax error.

CC-ing Andrew Sayers who added this feature.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [bash-completion] syntax error near unexpected token '<' on line 123 in bash_completion.d/git
  2010-07-25 11:12 [bash-completion] syntax error near unexpected token '<' on line 123 in bash_completion.d/git solsTiCe d'Hiver
  2010-07-25 11:49 ` Ævar Arnfjörð Bjarmason
@ 2010-07-25 20:01 ` Andrew Sayers
  2010-07-25 22:19   ` solsTiCe d'Hiver
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Sayers @ 2010-07-25 20:01 UTC (permalink / raw)
  To: solsTiCe d'Hiver; +Cc: git

"< <()" is indeed correct here: the first "<" is a normal shell
redirect, and the "<()" creates a sub-shell to read input from.  This
was the least messy way I could find to read variables into a shell.  "<
$()" won't do the job, and a normal pipe won't either:

$ FOO=parent ; echo child | { read ; FOO="$REPLY" ; } ; echo $FOO
parent
$ FOO=parent ; { read ; FOO="$REPLY" ; } < $( echo child ) ; echo $FOO
bash: child: No such file or directory
parent
$ FOO=parent ; { read ; FOO="$REPLY" ; } < <( echo child ) ; echo $FOO
child


Is "syntax error near unexpected token '<' on line 123" the complete
text of the error message you get?  bash 4.1.5 always prepends "bash: "
to such errors for me:

$ while false ; do echo foo ; done < ;
bash: syntax error near unexpected token `;'

If this is the complete error text, then I suspect you may have somehow
got bash completion in a non-bash shell.  Could you add this on line 98
and let me know what it says:

echo $BASH_VERSION $BASHOPTS

If it really is bash, $BASHOPTS might help me to replicate this problem
(or I might have to read the man page some more).

	- Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [bash-completion] syntax error near unexpected token '<' on line 123 in bash_completion.d/git
  2010-07-25 20:01 ` Andrew Sayers
@ 2010-07-25 22:19   ` solsTiCe d'Hiver
  2010-07-26 21:39     ` Andrew Sayers
  0 siblings, 1 reply; 7+ messages in thread
From: solsTiCe d'Hiver @ 2010-07-25 22:19 UTC (permalink / raw)
  To: Andrew Sayers; +Cc: git

Le dimanche 25 juillet 2010 à 21:01 +0100, Andrew Sayers a écrit : 
> bash 4.1.5 always prepends "bash: "
> to such errors for me:
> 
> $ while false ; do echo foo ; done < ;
> bash: syntax error near unexpected token `;'
> 
bash 4.1.7 does that too here.

> If this is the complete error text, then I suspect you may have somehow
> got bash completion in a non-bash shell.
> 
the complete message is:
/etc/bash_completion.d/git: line 123: syntax error near unexpected token
'<'
/etc/bash_completion.d/git: line 123: done < <(git config -z
--get-regexp '^(svn-remote\..*\.url|bash > \.showupstream)$' 2>/dev/null
| tr '\0\n' '\n ')

> Could you add this on line 98 and let me know what it says:
> echo $BASH_VERSION $BASHOPTS

When I add the above command at line 98, it shows it is really bash
running:
4.1.7(2)-release
cmdhist:expand_aliases:extglob:extquote:force_fignore:interactive_comments:progcomp:promptvars:sourcepath 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [bash-completion] syntax error near unexpected token '<' on line 123 in bash_completion.d/git
  2010-07-25 22:19   ` solsTiCe d'Hiver
@ 2010-07-26 21:39     ` Andrew Sayers
  2010-07-27  9:24       ` solsTiCe d'Hiver
  2010-07-27 10:43       ` solsTiCe d'Hiver
  0 siblings, 2 replies; 7+ messages in thread
From: Andrew Sayers @ 2010-07-26 21:39 UTC (permalink / raw)
  To: solsTiCe d'Hiver; +Cc: git

On 25/07/10 23:19, solsTiCe d'Hiver wrote:
<snip>
> When I add the above command at line 98, it shows it is really bash
> running:
> 4.1.7(2)-release
> cmdhist:expand_aliases:extglob:extquote:force_fignore:interactive_comments:progcomp:promptvars:sourcepath 

Hmm, that's interesting.  It's certainly bash, but I don't see
"login_shell" in the list, which suggests that something is loading bash
completion stuff in a non-interactive shell that has no need for it.
That might increase your your boot time a bit, so you may want to take
it up with Arch Linux when we've got to the bottom of this.

One way I've found to replicate your behaviour is to call bash as sh:

$ ln -s /bin/bash sh
$ ./sh -c 'echo $BASH_VERSION'
4.1.5(1)-release
$ ./sh contrib/completion/git-completion.bash
contrib/completion/git-completion.bash: line 123: ...

Again, this fits with the theory that some non-interactive shell is
wrongly loading this stuff.

This time, could you tell me what the following debug messages print:

echo $BASHOPTS -- $SHELLOPTS -- $POSIXLY_CORRECT
tr '\0' ' ' < /proc/$$/cmdline ; echo

Could you also have a look at /bin/sh and any other files that might be
(incorrectly?) symlinked to bash?

On a wider point, I consider the bash/sh behaviour above to be a bug,
whether or not it's the cause of this specific problem.  Unless someone
wants to tell me about git's long-standing policy against it, I'll try
and find some time to send in a patch warning usefully in this case.

	- Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [bash-completion] syntax error near unexpected token '<' on line 123 in bash_completion.d/git
  2010-07-26 21:39     ` Andrew Sayers
@ 2010-07-27  9:24       ` solsTiCe d'Hiver
  2010-07-27 10:43       ` solsTiCe d'Hiver
  1 sibling, 0 replies; 7+ messages in thread
From: solsTiCe d'Hiver @ 2010-07-27  9:24 UTC (permalink / raw)
  To: Andrew Sayers; +Cc: git

Le lundi 26 juillet 2010 à 22:39 +0100, Andrew Sayers a écrit : 
> This time, could you tell me what the following debug messages print:
> 
> echo $BASHOPTS -- $SHELLOPTS -- $POSIXLY_CORRECT
> tr '\0' ' ' < /proc/$$/cmdline ; echo
> 
cmdhist:expand_aliases:extglob:extquote:force_fignore:interactive_comments:progcomp:promptvars:sourcepath -- braceexpand:hashshell:interactive-comments:posix -- y
/bin/sh /usr/sbin/gdm

> Could you also have a look at /bin/sh and any other files that might be
> (incorrectly?) symlinked to bash?
> 
I have included gdm in the DAEMON list in my /etc/rc.conf. I tried to
run it from inittab in a more usual way and get the same ?!

When I looked at /usr/sbin/gdm, I found the cause of this problem, look
at that

#!/bin/sh
#
# A script so that
#    1) we read the standard system env vars
#    2) syadmins/integrators can add their own private options etc...

test -f /etc/profile && . /etc/profile

# Make sure LANG is set
#
if [ -z "$LANG" ]
then
  if [ -f /etc/sysconfig/language ]
  then
    LANG=`. /etc/sysconfig/language; echo $RC_LANG`
    export LANG
  fi
fi

exec /usr/sbin/gdm-binary "$@"

Note: it's not a custom archlinux script. This is straight from gdm
release 2.30.4

so it's a non-login shell (sh) script that source /etc/profile and
breaks standard behavior. no wonder that bash_completion stuff is run
there

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [bash-completion] syntax error near unexpected token '<' on line 123 in bash_completion.d/git
  2010-07-26 21:39     ` Andrew Sayers
  2010-07-27  9:24       ` solsTiCe d'Hiver
@ 2010-07-27 10:43       ` solsTiCe d'Hiver
  1 sibling, 0 replies; 7+ messages in thread
From: solsTiCe d'Hiver @ 2010-07-27 10:43 UTC (permalink / raw)
  To: Andrew Sayers; +Cc: git

it appears there is a bug in /etc/profile in archlinux that mis-detects
sh as bash and run bash specific script like bash_completion.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-07-27 10:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-25 11:12 [bash-completion] syntax error near unexpected token '<' on line 123 in bash_completion.d/git solsTiCe d'Hiver
2010-07-25 11:49 ` Ævar Arnfjörð Bjarmason
2010-07-25 20:01 ` Andrew Sayers
2010-07-25 22:19   ` solsTiCe d'Hiver
2010-07-26 21:39     ` Andrew Sayers
2010-07-27  9:24       ` solsTiCe d'Hiver
2010-07-27 10:43       ` solsTiCe d'Hiver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).