Hi everyone. I've been dusting off some old projects lately and have found that one of my programs no longer works as it should. I've done internet and forum searches and can't find an answer.
The program is one I shared here some time back. It is a basic Linux command line interpreter. It has the ability run external programs as well as five(so far) internal functions. The problem is that three of those internal commands no longer seem to work.
Here are the relevant sections of code:
/*built-in change directory command*/
/*built-in pipe support*/
puts("Sorry,pipe support is not yet implemented.");
/*built-in redirect support*/
puts("Sorry,redirection is not yet implemented.");
/*built-in version command*/
These above are the two sections of code responsible for determining command line input and taking the appropriate action.
else if(strchr(tmp,'>') || strchr(tmp,'<'))
else if(strcmp(intern_argv,"version") == 0)
External commands run as they should. The functions that recognize attempted use of pipes or redirects works. The trouble is that the internal cd, version, and exit commands no longer work. I get the built-in command not found error and the prompt simply returns.
gdb shows no abnormal working of the program.
gcc -Q show all functions are present and being compiled.
a simple gcc filename.c -o filename compilation works without warning or error.
Running it through the Scite editor produces the following:
>gcc -pedantic -Os -c nnsh.c -o nnsh.o -std=c99
nnsh.c: In function ‘show_prompt’:
nnsh.c:40: warning: ignoring return value of ‘getcwd’, declared with attribute warn_unused_result
nnsh.c: In function ‘cd’:
nnsh.c:56: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result
nnsh.c:58: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result
>Exit code: 0
All I really know at this point is that the program once worked as it was intended, and now it doesn't. I haven't changed any of those functions since it was last working.