Re: [LUNI] Shell questions

From: Martin Maney (maney@pobox.com)
Date: Mon Mar 12 2001 - 21:27:11 CST

  • Next message: Martin Maney: "Re: [LUNI] Shell questions"

    On Mon, Mar 12, 2001 at 08:26:03PM -0600, Jay Strauss wrote:
    > WHY???
    >
    > I see it works, but I don't get it. why to I have to escape before and
    > after the inside escape

    > > > $ echo "Hi I'm fine"

    Okay, this is the way I would do it myself unless I was being intentionally
    cute (or obscure, or something). In fact, I would suggest that you consider
    the double quotes to be the normal ones for shell (and, because of the shell
    syntax, most other Unix-native languages). They allow variable
    substitution, and some of the metas still need escaping, but it works fine
    in many common cases.

    > > $ echo Hi\ I\'m\ fine.

    As I said, this is cute. Instead of hiding the single quote by making it
    part of a string literal, this uses per-character escapes for the single
    quote and the blanks. Didn't really need the blanks escaped here, since
    echo just repeats all its arguments, but doing this makes the shell pass
    echo one string, and so this is the exact analog to "Hi I'm fine" (except I
    added a period for some reason).

    Each backslash escapes the immediately following character, and only that
    character (okay, there's the octal and hex ways of describing a character,
    but forget that for now). So this is 'H', 'i', escaped blank which is ' ',
    'I', escaped single quote which is hard to write in that fashion so I'll say
    "'", "m", escaped blank again " ", "f", "i", "n", "e", ".".

    Clear as mud now? ;-)

    -=-
    Linux Users Of Northern Illinois: General Discussion Mailing list.
    For unsubscription, archives, and announcements only see http://luni.org



    This archive was generated by hypermail 2b29 : Mon Mar 12 2001 - 21:27:17 CST

  •