Changeset e6ee171 in rtems


Ignore:
Timestamp:
Jul 23, 2008, 8:28:13 PM (11 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.9, master
Children:
75d16dd8
Parents:
bd5762d
Message:

2008-07-23 Joel Sherrill <joel.sherrill@…>

  • libmisc/shell/shell_script.c: Clean up code for command not found including the error message.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rbd5762d re6ee171  
     12008-07-23      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * libmisc/shell/shell_script.c: Clean up code for command not found
     4        including the error message.
     5
    162008-07-23      Joel Sherrill <joel.sherrill@oarcorp.com>
    27
  • cpukit/libmisc/shell/shell_script.c

    rbd5762d re6ee171  
    4848)
    4949{
     50  int sc;
     51
    5052  /*
    5153   *  If the user script name starts with a / assume it is a fully
     
    5456  if ( userScriptName[0] == '/' ) {
    5557    strcpy( scriptFile, userScriptName );
    56     return 0;
    57   }
    58 
    59   /*
    60    *  For now, the provided name is just turned into a fully
    61    *  qualified path name and used.  There is no attempt to
    62    *  search along a path for it.
    63    */
    64 
    65   getcwd( scriptFile, PATH_MAX );
    66   /* XXX should use strncat but what is the limit? */
    67   strcat( scriptFile, "/" );
    68   strcat( scriptFile, userScriptName );
     58  } else {
     59    /*
     60     *  For now, the provided name is just turned into a fully
     61     *  qualified path name and used.  There is no attempt to
     62     *  search along a path for it.
     63     */
     64
     65    /* XXX should use strncat but what is the limit? */
     66    getcwd( scriptFile, PATH_MAX );
     67    strcat( scriptFile, "/" );
     68    strcat(
     69      scriptFile,
     70      ( (userScriptName[0] == '.' && userScriptName[1] == '/') ?
     71         &userScriptName[2] : userScriptName)
     72    );
     73  }
     74
     75  sc = access( scriptFile, R_OK );
     76  if ( sc ) {
     77    return -1;
     78  }
     79
    6980  return 0;
    7081
     
    157168  sc = findOnPATH( argv[getopt_reent.optind], scriptFile );
    158169  if ( sc ) {
    159     fprintf( stderr, "%s not found on PATH\n", argv[0] );
     170    fprintf( stderr, "%s: command not found\n", argv[0] );
    160171    return -1;
    161172  }
     
    228239  sc = findOnPATH( argv[0], scriptFile );
    229240  if ( sc ) {
    230     fprintf( stderr, "%s not found on PATH\n", argv[0] );
     241    fprintf( stderr, "%s: command not found\n", argv[0] );
    231242    return -1;
    232243  }
Note: See TracChangeset for help on using the changeset viewer.