home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] acceptable bourne shell function names

  • Subject: Re: [OCLUG-Tech] acceptable bourne shell function names
  • From: Walt Sullivan <walts [ at ] magma [ dot ] ca>
  • Date: Tue, 30 Jun 2009 00:18:10 -0400
>From "man bash"

   Shell Function Definitions
       A shell function is an object that is called like a simple
command and executes a compound
       command with a new set of positional parameters.  Shell functions
are declared as follows:

       [ function ] name () compound-command [redirection]
              This  defines  a  function named name.

....

       name   A word consisting only of alphanumeric characters and
underscores,  and  beginning
              with  an alphabetic character or an underscore.  Also
referred to as an identifier.

RTFM

"git-dirstatus" is not a "name", "git_dirstatus" is.

On Fri, 2009-06-26 at 18:53 -0400, Michael P. Soulier wrote:
> Greetings,
> 
> I'm having an odd issue with my bash config. In it I'm defining functions like
> 
> git-dirstatus()
> {
>     do some work
> }
> 
> Sourcing this in my .bashrc works fine in a shell, but if I source my .bashrc
> from my .xsession file during X login, I get a login failure, with a complaint
> about the function name in my .xsession-errors file.
> 
> If I use underscores instead of the dash
> 
> ie.
> git_dirstatus()
> 
> then it works in both.
> 
> I've tried an .xsession with
> 
> #!/bin/sh
> #!/bin/bash
> 
> neither seems to make a difference. I have no idea why this situation would be
> different just on X login.
> 
> Any ideas?
> 
> Thanks,
> Mike
> _______________________________________________
> Linux mailing list
> Linux [ at ] lists [ dot ] oclug [ dot ] on [ dot ] ca
> http://oclug.on.ca/mailman/listinfo/linux