Extend KMacroExpander for shell-expansion?

Oswald Buddenhagen ossi at kde.org
Fri Jul 18 22:22:35 BST 2008


On Fri, Jul 18, 2008 at 08:54:11PM +0200, Andreas Pakulat wrote:
> I have to admit that after looking through the API and implementation
> I'm not quite sure how to properly implement something like this:
> 
> FOO=BAR
> BAZ=$FOO
> SOMEVAR=$BAZ
> 
> where I of course want SOMEVAR=BAR as result.
>
well, as given above, the problem is trivial, obviously.
note that you have to do the "command splitting" and the assignments
yourself. i don't think this can be reasonably generalized.

> The problem I'm having here is that the list of variables I have as
> input is not ordered like above. [...]
> Am I just missing something or is there simply no way to do this?
> 
not via a static map expansion, obviously. you need to put the parsed
assignments as-is into a map and pass that to a dynamic expander (which
(on unix) is a subclass of kwordmacroexpander, operates recursively and
has an infinite recursion detector (either by simply limiting the depth
or by marking variables which are currently being expanded)).

> > note that KMacroExpander is unfit to implement the totally braindead
> > semantics of dos-style variable expansion - and i suppose we want to use
> > platform-native expansions?
> 
> If possible I guess thats the "easiest way out"...
> 
it's just a question of what the user expects. we trimmed kshell and
kmacroexpander to deal with native variable expansions, so far.

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Confusion, chaos, panic - my work here is done.




More information about the kde-core-devel mailing list