This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On Tuesday 10 September 2013 17:32:21 Patrick 'P. J.' McDermott wrote:
> On 2013-09-10 17:02, Mike Frysinger wrote:
> > i dislike the missing `local` decls for output and rc. but those aren't
> > exactly specified in POSIX (even if every reasonable shell supports it).
> > maybe do a double sub-shell instead ?
> >
> > try_trace() {
> > (
> > output=$(.....)
> > rc=$?
> > printf ....
> > exit $rc
> > )
> > }
>
> I discussed this in the original thread [1]. There are shells that
> don't support local, so I'd rather avoid using it. I proposed using a
> subshell as you've suggested (though the outside curly braces aren't
> necessary on any shell, as far as I know â either way the function is
> defined as a compound list of commands). At the time, though, no one
> indicated any preferences. So I think I'll adjust this to use a
> subshell.
i use this style as it's what people are used to -- they have in their mind
that a func must be bracketed by {...}.
if you do choose to omit those, please make sure to add an explicit comment so
future peeps don't get confused.
# The use of (...) vs {...} for the body of the func is by design -- we
# want a subshell to avoid the vars leaking into the caller.
try_trace() (
....
)
-mike
Attachment:
signature.asc
Description: This is a digitally signed message part.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |