Re: Bash commands: maybe they want to drive us crazy?

From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 07/01/04

  • Next message: pean: "Rdms (MySQL) as backend for OpenLDAP"
    Date: 1 Jul 2004 05:47:10 GMT
    
    

    On 2004-07-01, GP wrote:
    > Bill Unruh wrote:
    >
    >> ]find -iname . "*IPv6*"
    >>
    >> -iname is an option which takes one argument. That argument to the option in this case is
    >> '*IPV6*' (NOT "*IPv6*" because the latter would cause the shell to expand
    >> the *s, not find)
    >
    > Ok. Let's examine this first argument. Mr Unruh pretends that
    >
    > double quotes cause the shell to expand the *
    >
    > whereas
    >
    > single quotes would cause the find command to expand the *

       Quite right; Bill was wrong.

    > Which means that a shell command and the shell itself are two very different
    > things.

       Of course they are two different things.

    > Well... if that's not new Linux to you, it certainly is to me and there is
    > absolutely no doubt I could have a rather lenghty discussion on the matter.
    > But, since "I" know nothing, in a socratian kind of way, I'll let my system answer.
    >
    > EVERYTHING YOU ALWAYS WANTED TO KNOW ABOUT QUOTES
    > (but were too afraid to ask ;)
    >
    > ~$ echo `$LOGNAME`
    > -bash: gp: command not found
    >
    > The shell seems to expect a command inside back quotes (or back ticks, as they
    > are often refered to). It's not pleased with a variable. Let's feed it a command!
    >
    > ~$ echo `ps`
    > PID TTY TIME CMD 1779 pts/2 00:00:00 bash 1856 pts/2 00:00:00 ps
    >
    > The shell interprets the command.
    >
    > ~$ echo '$LOGNAME'
    > $LOGNAME
    >
    > Here, the single quotes turns the shell into parrot. Let's feed it a command.
    >
    > ~$ echo 'ps'
    > ps
    >
    > Same here. Sorry for this abominable untechnical language, but the single
    > quotes do turn the shell into a parrot.
    >
    > ~$ echo "$LOGNAME"
    > gp
    >
    > Double quotes expand the variable into its value.
    >
    > ~$ echo "ps"
    > ps
    >
    > But dumbly echo the command exactly as single quotes do.
    >
    > As we all know:
    >
    > If we include something inside of double-quotes, everything loses its special
    > meaning except for the variable operator ($), the back-slash (\), the back-tick (`)
    >
    > http://www.linux-tutorial.info/modules.php?name=Tutorial&pageid=20
    >
    > Thanks Linux tutorial!
    >
    > So, please cd to /etc and issue the following commands:
    >
    > find . -iname '*net*'
    > find . -iname "*net*"
    >
    > What's the difference? None! Why? Because, since there is no $ , \ or `` inside
    > the double quotes, it is exactly equivalent to single quotes.

         Exactly.

    > Conclusion:
    >
    > Contrary to the pretention of Mr Unruh, there is absolutely no difference
    > between a shell and a shell command interpretation.

         What are you talking about??

         A shell is a program that interprets commands (from the terminal
         or from a file) according to strict and well-defined rules.

         The shell parses the command line, performs various expansions,
         and passes the result to the command as an array of arguments,
         whether the command is built into the shell (cd, echo, type) or
         is an external command (find, grep, date).

    -- 
        Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
        ===================================================================
        My code (if any) in this post is copyright 2004, Chris F.A. Johnson
        and may be copied under the terms of the GNU General Public License
    

  • Next message: pean: "Rdms (MySQL) as backend for OpenLDAP"

    Relevant Pages

    • Re: Bash commands: maybe they want to drive us crazy?
      ... > Bill Unruh wrote: ... > single quotes would cause the find command to expand the * ... > Which means that a shell command and the shell itself are two very different ...
      (comp.os.linux.misc)
    • Re: Using Shell command
      ... >From what I've been able to tell, Shell doesn't like Start. ... Single quotes wouldn't work, Paint didn't like them, so I had to double up ... The vbmaximizedfocus works on the command window, ... Start would just open another command window with the item in quotes as the ...
      (microsoft.public.access.modulesdaovba)
    • Re: Background subprocess help?
      ... This description does not correspond to the command above. ... command is confusing because it uses quotes in a strange way. ... meant at the linguistic level and the inner quotes are shell quotes. ... d> processes and/or callbacks and 50+ lines of python code. ...
      (comp.lang.python)
    • Re: Rsync --exclude option
      ... I don't think you are doing that, otherwise your use of the rsync ... so that they are not interpreted by the shell at all. ... to protect them from expansion. ... If the expansion tries to produce quotes, ...
      (comp.unix.shell)
    • Re: Bash commands: maybe they want to drive us crazy?
      ... Bill Unruh wrote: ... single quotes would cause the find command to expand the * ... Which means that a shell command and the shell itself are two very different ...
      (comp.os.linux.misc)