Dixi quod…

>Commit ID:     1005085AA537A17A752

>Log message:
>bring back ${ foo;} sans dot.mkshrc patch, using a temporary file, and as 
>experimental feature

This does not entirely do what I want. I originally wanted:

• acquire a tempfile (fd A)
• unlink the tempfile
• relocate fd A to FDBASE and mark it as CLOEXEC => fd A'
• backup stdout
• dup2 fd A' into fd 1 (which is not CLOEXEC then)
• run the op tree
• [close or fsync(rather not) fd 1]
• restore fd 1 from backup stdout
• read the content from fd A'

In many combinations, this all did not work, or not always
work (most funny: '${ ls;}' fails, these all work: '${ :;ls;}'
'${ ls;:;}' '${ ls||:;}' '${ { ls; }; }'), so I had to:

• acquire a tempfile (fd A)
• relocate fd A to FDBASE and mark it as CLOEXEC => fd A'
• get an shf SA on fd A'
• backup stdout
• dup2 fd A' into fd 1' (which is not CLOEXEC then)
• run the op tree
• close shf SA (taking fd A' with it)
• restore fd 1 from backup stdout (taking fd 1' with it)
• open a new shf SB on the tempfile name
• unlink the tempfile
• read the content from shf SB

I could not even keep the shf open (SA is opened for
writing, SB for reading, but that was not the issue)!
No matter what I did, debugging shellfs showed that,
after returning from the tree execution, the file had
a size of 0 bytes (using fstat() on the fd A').

So, if anyone’s got a better idea… patches welcome.
Otherwise: PLEASE TEST THIS (and the 'sh -c' commit)!

Thanks in advance,
//mirabilos
-- 
Solange man keine schmutzigen Tricks macht, und ich meine *wirklich*
schmutzige Tricks, wie bei einer doppelt verketteten Liste beide
Pointer XORen und in nur einem Word speichern, funktioniert Boehm ganz
hervorragend.           -- Andreas Bogk über boehm-gc in d.a.s.r

Reply via email to