Link to home
Start Free TrialLog in
Avatar of ahoffmann
ahoffmannFlag for Germany

asked on

bash };:

I'm asking in this topic 'cause I think most bash experts can be found here;-)

Here we go: can somebody please explain how the 2'nd and 3'rd : are interpreted by bash in following command.

     :() {;:};:

I assume bash uses them as modifiers.

NOTE, this command is dangerous, take care when using.
Anyway, my question is not just a joke, 'cause I'm using scripts like this:
     # ..
     debug=echo     # set to : to switch debug off
     # ..
     $debug some command and args
            some command and args
     # ..
Avatar of kyrmit
kyrmit
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER CERTIFIED SOLUTION
Avatar of kyrmit
kyrmit
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ahoffmann

ASKER

> In your case however, you overwrite the default ':' command by appending (). Which is the way to create a function.

Hmm, does this mena that bash's parser does not require the function keyword to define a new function, **and** that a function name may contain punctation characters.
Or is this a result of a lazy grammer definition for the parser?

Anyway, if so, I know know why I avoided using bash since the beginning of ages ...
Hi
  in bash, the function command is optional. You can define functions with or without it. I don't think that it was intended that you can replace the : command. Obviously, you can in the version I tried.

The function name _should_ be only alphanumerical characters and '_'.

K.
kyrmit, this was a perfect answer, even the solution (bash) does not satisfy my requirements.
Enjoy the increased points ;-)