zsh-workers
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-workers@zsh.org
Subject: Re: first adventures
Date: Thu, 30 Oct 2014 18:59:52 -0700	[thread overview]
Message-ID: <5452ED18.7070208@eastlink.ca> (raw)
In-Reply-To: <141029210738.ZM15833@torch.brasslantern.com>

[-- Attachment #1: Type: text/plain, Size: 2271 bytes --]

On 10/29/2014 09:07 PM, Bart Schaefer wrote:
> On Oct 29,  4:31pm, Ray Andrews wrote:
I believe you have done it, sir:

    #!/usr/bin/zsh


    typeset -g TLC
    TRAPDEBUG()
    {

       # This works perfectly to print directly to screen:
       #(( $#functrace == 1 )) && print -u2 "$ZSH_DEBUG_CMD"

       # Top Level Command capture:
       (( $#functrace == 1 )) && TLC="${ZSH_DEBUG_CMD}"
    }

    test()
    {
       # We only want the arguments so chop off the command itself:
       chop_cmd=${TLC/$0/}
       echo
       print -ru2 "My unexpanded arguments were: $chop_cmd"
       print -u2 "\n...and my arguments broken to an array:\n"

       array=("${=chop_cmd}")

       print -ru2 "two:   $array[2]"
       print -ru2 "three: $array[3]"
       print -ru2 "four:  $array[4]"
       print -ru2 "five:  $array[5]"
       print -ru2 "six:   $array[6]"
    }

It is proof against glob or variable expansion, it swallows redirection, 
and it doesn't mind compound command lines, however it does expand 
bangchar, as wanted:

    $ test ls $PWD; test ls g* > /dev/null; test l ,H $PWD/test; test 'I
    wandered \n lonely as a cloud'; test "that \n floats on high"

    My unexpanded arguments were:  ls $PWD

    ...and my arguments broken to an array:

    two:   ls
    three: $PWD
    four:
    five:
    six:
    My unexpanded arguments were:  ls g* > /dev/null

    ...and my arguments broken to an array:

    two:   ls
    three: g*
    four:  >
    five:  /dev/null
    six:

    My unexpanded arguments were:  l ,H $PWD/test

    ...and my arguments broken to an array:

    two:   l
    three: ,H
    four:  $PWD/test
    five:
    six:

    My unexpanded arguments were:  'I wandered \n lonely as a cloud'

    ...and my arguments broken to an array:

    two:   'I
    three: wandered
    four:  \n
    five:  lonely
    six:   as

    My unexpanded arguments were:  "that \n floats on high"

    ...and my arguments broken to an array:

    two:   "that
    three: \n
    four:  floats
    five:  on
    six:   high"


... I think I can't even  quibble about the quoted strings not being 
treated as single arguments
because I can't have it both ways--the whole exercise is to have zero 
processing.

And I don't even need to rape the src.






  parent reply	other threads:[~2014-10-31  1:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-26 17:20 Ray Andrews
2014-10-26 17:50 ` Bart Schaefer
2014-10-26 18:04   ` Bart Schaefer
2014-10-26 18:41     ` Ray Andrews
2014-10-26 19:57   ` Ray Andrews
2014-10-26 21:04     ` Bart Schaefer
2014-10-27  3:48       ` Ray Andrews
2014-10-27  6:08         ` Bart Schaefer
2014-10-26 17:52 ` Peter Stephenson
2014-10-28 17:48   ` Ray Andrews
2014-10-29  4:05     ` Bart Schaefer
2014-10-29 15:41       ` Ray Andrews
2014-10-29 20:46         ` Bart Schaefer
2014-10-29 23:31           ` Ray Andrews
2014-10-30  4:07             ` Bart Schaefer
2014-10-30 17:22               ` Ray Andrews
2014-10-31  1:59               ` Ray Andrews [this message]
2014-10-31  2:59                 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5452ED18.7070208@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).