[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ASH strangeness




Hello


Every time I try to work with shell scripting on Axis development board I
get confused about job control.  To demonstrate this problem I wrote some 
little built-in test command for "ash".  It looks like:

int mytestcmd(int argc, char **argv)
{
  char c[255];
  
  while (fgets(c, sizeof(c), stdin)) 
    fprintf(stdout,"%s",c);
   
  return 0;
}

It just grabs standart input and prints it on standart output:
# cat /etc/passwd | mytest
root:AiADGkJIfIlXk:0:0:Administrator:/:/bin/sh
nobody:*:99:99:Nobody:/:

But only for the first time!! "stdin" seems to be empty(NULL) for the
second and further tries:
# cat /etc/passwd | mytest
# 

The same trick works without any problems on Intel platform with same
version of "ash".
Could you give me some reference where to look for a bug?  I attach diff
of my changes to this letter.  Thank you!

Evaldas

diff -u -r --new-file ash/builtins.def ash.new/builtins.def
--- ash/builtins.def    Thu Jul 13 15:34:45 2000
+++ ash.new/builtins.def        Wed Oct  4 20:56:17 2000
@@ -51,6 +51,7 @@
 # NOTE: bltincmd must come first!
 
 bltincmd       builtin
+mytestcmd      mytest
 #alloccmd      alloc
 bgcmd -j       bg
 breakcmd       break continue
diff -u -r --new-file ash/elinux.c ash.new/elinux.c
--- ash/elinux.c        Fri Jul 14 06:00:29 2000
+++ ash.new/elinux.c    Wed Oct  4 20:57:01 2000
@@ -83,3 +83,15 @@
   
   return 0;
 }
+
+int
+mytestcmd(int argc, char **argv)
+{
+  char c[255];
+  
+  while (fgets(c, sizeof(c), stdin)) 
+    fprintf(stdout,"%s",c);
+   
+  return 0;
+}
+