zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: aliases not getting expanded inside functions?
Date: Mon, 13 Jan 2003 18:48:27 +0000	[thread overview]
Message-ID: <1030113184827.ZM21872@candle.brasslantern.com> (raw)
In-Reply-To: <15906.65149.206767.381472@fisica.ufpr.br>

On Jan 13,  3:59pm, Carlos Carvalho wrote:
}
}  >      fields=( "${(@s:;:)dataline}" )	# Answers your other question
} 
} Doesn't work for me:

Hrm.  I was sure I'd tried it, but on your input I get the same result
you do.  Well, there's always:

    IFS=';' eval 'fields=( $=dataline )'

However, it occurs to me that with dataline='...;";";...' -- that is, a
quoted semicolon in the input data -- there's no quick solution that's
going to do exactly what you need.

}  >    while IFS=';' read rate capital etc.
} 
} Yes, I didn't do it because I had hope to one day do a block move
} via arrays. Also, reading to a parameter first makes it easier to do
} some pre-processing like quote removal, otherwise I have to do it
} field by field after reading.

[...]

}  >    fields[capital]=$((fields[capital]+fields[interest]))
} 
} This makes the program more cumbersome to write and read because all
} variables become quite long-named...

So don't name the array "fields", name it "f" or some such.  Three extra
characters (e.g. $f[capital] instead of $capital) for a whole lot less
complexity elsewhere.  And quote removal may be as easy as:

	f=( ${${(kv)f#\"}%\"} )

(Whether it's actually that easy depends on your input data, e.g., you
might also need to convert \" to ", but I think `read' will have done
that for you already.)


  reply	other threads:[~2003-01-13 18:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-03 15:31 Carlos Carvalho
2003-01-03 15:39 ` Zefram
2003-01-03 15:45 ` Phil Pennock
2003-01-03 17:24   ` Carlos Carvalho
2003-01-03 17:44     ` Phil Pennock
2003-01-03 18:10       ` Carlos Carvalho
2003-01-03 18:54         ` Zefram
2003-01-06  8:29           ` Carlos Carvalho
2003-01-06 12:54             ` Bart Schaefer
2003-01-11  3:19               ` Carlos Carvalho
2003-01-11 18:40                 ` Bart Schaefer
2003-01-13 17:59                   ` Carlos Carvalho
2003-01-13 18:48                     ` Bart Schaefer [this message]
2003-01-13 21:40                       ` Carlos Carvalho
2003-01-14  5:10                         ` Bart Schaefer
2003-01-14 11:44                           ` Roman Neuhauser

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=1030113184827.ZM21872@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /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).