Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: 'export -p' lacks POSIX output



On Oct 23,  2:00pm, Martijn Dekker wrote:
} Subject: Re: 'export -p' lacks POSIX output
}
} Op 22-10-16 om 20:24 schreef Bart Schaefer:
} > Would anyone object if this just happened all the time, rather than
} > depending on POSIXBUILTINS + "export"?
} 
} After the patch, variables with a non-scalar type get output such as:
} 
} export -i10 SHLVL=2
} 
} Option flags to 'export' other than -p are not POSIX, and POSIX
} specifies output without any flags for 'export -p'.

We may have to settle for incompatibility here.  As I mentioned, there
is no way (without either a large code change or introducing yet another
global variable [*]) for the code that prints the command name to know
whether "typeset -p", "declare -p", "export -p", etc. were used.  If the
non-string (note, integer is not non-scalar) flags are eliminated, the
state won't be properly reflected if the commands are re-input.

If you're writing a POSIX-compatible script you shouldn't declare anything
integer in the first place, should you?

} In any case, if the output needs to be conditional upon POSIXBUILTINS
} anyway, I reckon you might as well not change the behaviour at all if
} POSIXBUILTINS is not active.

The selection of the command name to print and the output of the type
dinstinction flags are in separate sections of the code, so that's not
really a concern.  I think the addition of -g for typeset of non-local
parameters in function scope is useful (waiting to hear if anyone has
objections) and that doesn't depend on POSIXBUILTINS.

[*] Of course if such a variable WERE introduced I could take advantage
of it in zsh/param/private.  I was trying to avoid invasive changes for
that module but if it's needed for other reasons I'd be less shy.



Messages sorted by: Reverse Date, Date, Thread, Author