Skip to content

Latest commit

 

History

History
54 lines (49 loc) · 861 Bytes

File metadata and controls

54 lines (49 loc) · 861 Bytes

myshell

TODO:

  • man
  • ps: ps -e ps -ef ps -aux
  • tree: print tree structure still has some bugs
  • redirection
  • pipe
  • background

Useage

to compile project

make all

to remove compiled result

make clean

Development Template

function template:

#include "cmd_template.h"

int cmd_template(int argc, char *argv[]) {
    if (argc < n) {
        fprintf(stderr, "Usage: %s\n", argv[0]);
        return 1;
    }
    // TODO
    return 0;
}

header template:

#ifndef CMD_TEMPLATE_H_
#define CMD_TEMPLATE_H_

int cmd_template(int argc, char *argv[]);

#endif

add header to main.h:

#include "cmd_template.h"

register command in main.c/regist_func():

static HASH_NODE *regist_func(void) {
    // other commands
    hash_register(hash_table, "cmd_template", cmd_template);
    return NULL;
}