Bug #412

at times xadmin fails to parse commands

Added by Madars almost 5 years ago. Updated over 4 years ago.

Status:ClosedStart date:05/13/2019
Priority:Normal (Code 4)Due date:
Assignee:-% Done:

100%

Category:-
Target version:-

Description

For example:

NDRX 2> 
NDRX 2> ls -alrt
Command `ls' not found!
NDRX 2> 
NDRX 2> 
NDRX 2> 
NDRX 2> psc
* Shared resources opened...
* Enduro/X back-end (ndrxd) is not running

* ndrxd PID (from PID file): 26567
* ndrxd idle instance started.
psc: invalid option -- 'l'
Invalid options, see `help'.
NDRX 2> 
NDRX 2> 
NDRX 2> 
NDRX 2> 
NDRX 2> psc
* ndrxd PID (from PID file): 26567
psc: invalid option -- 'r'
Invalid options, see `help'.
NDRX 2> 
NDRX 2> 
NDRX 2> 
NDRX 2> psc
* ndrxd PID (from PID file): 26567
psc: invalid option -- 't'
Invalid options, see `help'.
NDRX 2> 
NDRX 2> 
NDRX 2> quit

History

#1 Updated by Madars over 4 years ago

Seems like not resetting optarg:

NDRX 1> xadmin
Command `xadmin' not found!
NDRX 1> 
NDRX 1> 
NDRX 1> psc
* ndrxd PID (from PID file): 12148
psc: invalid option -- 'U'
Invalid options, see `help'.
NDRX 1> psc
* ndrxd PID (from PID file): 12148
psc: invalid option -- 'P'
Invalid options, see `help'.
NDRX 1> 
NDRX 1> 
NDRX 1> 
NDRX 1> 
NDRX 1> psc
* ndrxd PID (from PID file): 12148
psc: invalid option -- 'L'
Invalid options, see `help'.
NDRX 1> 
NDRX 1> 
NDRX 1> psc
* ndrxd PID (from PID file): 12148
psc: invalid option -- 'D'
Invalid options, see `help'.
NDRX 1> 
NDRX 1> 
NDRX 1> 

According to https://www.systutorials.com/docs/linux/man/3-getopt/

The variable optind is the index of the next element to be processed in argv. The system initializes this value to 1. The caller can reset it to 1 to restart scanning of the same argv, or when scanning a new argument vector.

#2 Updated by Madars over 4 years ago

Looks like needs to convert:

diff --git a/libnstd/nclopt.c b/libnstd/nclopt.c
index 800898a..a3ce331 100644
--- a/libnstd/nclopt.c
+++ b/libnstd/nclopt.c
@@ -39,6 +39,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <unistd.h>

 /* Missing on AIX */
 #ifdef HAVE_GETOPT_H
@@ -49,11 +50,10 @@
 #include <nclopt.h>
 #include <ndebug.h>

+
 #include <ubf.h>

 /*---------------------------Externs------------------------------------*/
-extern int optind, optopt, opterr;
-extern char *optarg;

from extern to unistd.h

#3 Updated by Madars over 4 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

#4 Updated by Madars over 4 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF