I think I discovered a bug in ksh.
works with all shells, including ksh in normal mode.
But does not work with ksh -x: sh -x or bash -x or zsh -x do it correctly:
I think I discovered a bug in ksh.
works with all shells, including ksh in normal mode.
But does not work with ksh -x: sh -x or bash -x or zsh -x do it correctly:
I guess I don't see what's wrong.
It looks like ksh is running the parts of the pipelines in different threads (so you see jumbled output in the trace), but both x and y are assigned empty values and the echo $x and echo $y seem to have done the right thing. What am I missing?
If you mean that the trace output from bash and zsh don't show redirection operations performed by the shell, I don't think that is a ksh bug.
Last edited by Don Cragun; 11-20-2013 at 05:53 PM..
Reason: Add final comment on redirections.
x definitely gets the value "1> /dev/null" assigned when run with "ksh -x".
The lines without a + are actually printed on the screen.
I had worked on a script where a "ksh -x" run produced a total different result, compared to a normal run with "ksh".
Here is another variant of the above script:
I can confirm the results from post #3 using 93u+ 2012-08-01.
Regards,
Alister
---------- Post updated at 05:43 PM ---------- Previous update was at 04:48 PM ----------
Taking a closer look at this, and experimenting with various oneliners, I don't think this is a bug.
ksh writes the trace to stderr and stderr is redirected by the scripts above.
bash doesn't trace redirections. ksh does. Redirections are set aside during parsing and are processed after the other command steps. Just before processing the 2>&1 redirection, ksh prints it to stderr. Then stderr is redirected. Further redirections appear on stdout. In my example, that's the file named stdout; in MadeInGermany's script, it is the pipe leading from the command substitution to the parent shell.
Regards,
Alister
Last edited by alister; 11-20-2013 at 08:03 PM..
These 5 Users Gave Thanks to alister For This Post:
Then let's call it a shortcoming.
It looks like -x mode uses stderr, and can conflict with redirection in the shell code.
Then, why stderr and not another file descriptor?
Maybe that was not available on all Unix system 1988?
Then let's call it a shortcoming.
It looks like -x mode uses stderr, and can conflict with redirection in the shell code.
Then, why stderr and not another file descriptor?
Probably because that's exactly what stderr is there for. Being 'clever' about it would make obvious things, like redirecting a trace's output into a file, difficult. A shell can't make too many assumptions about what you intend to do with it.
You, the programmer however, are allowed to make more assumptions. Why were you using the same file descriptor as the debugger?
Last edited by Corona688; 11-21-2013 at 03:30 PM..
Hello,
Im using the g++(g++ Ubuntu/Linaro 4.4.4-14ubuntu5 4.4.5) and im trying to compile a small snippet code and got into an endless loop.I recompiled that in VS2010 under Windows 7 and the answer is as expected.so i wonder is this a bug of g++?here is my code.
#include<iostream>
using... (5 Replies)
Hi
I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email.
For example
-------
Script ABC
-------
a.ksh
b.ksh
c.ksh
I need to call all three scripts execute them and... (2 Replies)
#!/bin/bash
if then
#echo "infinite loop"
exit 0
fi
when I run this file I get the following error:
./test_infinite_loop: line 5: syntax error near unexpected token `fi'
./test_infinite_loop: line 5: `fi'
:confused: (4 Replies)
Hi All,
I am using Red Hat Linux on my servers. The problem that I am facing is, sometimes the /opt usage on the server shows used percentage as 100% , when actually it is simply 20%.
When I reboot the system, it comes back to 20%.Is this a bug in the system or my settings have gone wrong... (1 Reply)
Is this a bug in ksh on HPUX 11i or is read impromperly documented?
INPUT
Thu Jan 18 09:14:52 PST : CIFS: Virus Detected - File ONTAP_ADMIN$\vol\vol0\DDD\Ventana\Strattoni\Race Stuff\Rumor.exe in share DDD accessed by client CLIENT (111.11.11.111) running as user USER is infected. The filer... (3 Replies)
I've been playing around with sed for a few days now and find that regular expressions never work inside sed s/// on Mac OS 10.2.5. Has anyone else bumped up against this problem?
For example, the "sed" segment of the following always fails no matter how items are escaped:
cd... (12 Replies)