Skip to content

Commit

Permalink
bugfixes for v1.2.0: mac makefile bugfix on empty variable and source…
Browse files Browse the repository at this point in the history
… builtin bugfix allowing to parse files with jsh alias expansion
  • Loading branch information
jovanbulck committed Dec 8, 2014
1 parent 8f46cac commit 50a749a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ ECHO_LIBS = echo "Linking jsh with the following libraries: $(LIBS
UNAME_S = $(shell uname -s)

ifeq ($(UNAME_S), Darwin)
IS_BSD
IS_BSD=1
else ifeq ($(UNAME_S), FreeBSD)
IS_BSD
IS_BSD=1
endif

ifeq ($(UNAME_S), Darwin)
Expand Down
10 changes: 10 additions & 0 deletions jsh-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ void freecomdlist(comd *list) {
}
}

/**
* TODO also take aliases etc into account
*/
int parse_from_file(char *line) {
char *resolved = resolvealiases(line);
int rv = parseexpr(resolved);
free(resolved);
return rv;
}

/*
* parseexpr: parses the '\0' terminated expr string recursivly, according to the 'expr' grammar.
* returns exit status (EXIT_SUCCESS || !EXIT_SUCCESS) of executed expression
Expand Down
5 changes: 5 additions & 0 deletions jsh-parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ struct comd {
};
typedef struct comd comd;

/**
* TODO also take aliases etc into account
*/
int parse_from_file(char *line);

/*
* parseexpr: parses the '\0' terminated expr string recursivly, according to the 'expr' grammar.
* returns exit status (EXIT_SUCCESS || !EXIT_SUCCESS) of executed expression
Expand Down
6 changes: 3 additions & 3 deletions jsh.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void things_todo_at_start(void) {
// read ~/.jshrc if any
if (LOAD_RC) {
path = concat(3, gethome(), "/", RCFILE);
parsefile(path, (void (*)(char*)) parseexpr, false);
parsefile(path, (void (*)(char*)) parse_from_file, false);
free(path);
}

Expand Down Expand Up @@ -306,7 +306,7 @@ void things_todo_at_exit(void) {
bool dbg = DEBUG;
DEBUG = false;
char *path = concat(3, gethome(), "/", LOGOUT_FILE);
parsefile(path, (void (*)(char*)) parseexpr, false);
parsefile(path, (void (*)(char*)) parse_from_file, false);
free(path);
DEBUG = dbg;
printdebug("'%s' executed", LOGOUT_FILE);
Expand Down Expand Up @@ -571,7 +571,7 @@ int parse_built_in(comd *comd, int index) {
break;
case SRC:
CHK_ARGC("source", 1);
parsefile(comd->cmd[1], (void (*)(char*)) parseexpr, true); // errormsg if file not found
parsefile(comd->cmd[1], (void (*)(char*)) parse_from_file, true); // errormsg if file not found
return EXIT_SUCCESS;
break;
default:
Expand Down

0 comments on commit 50a749a

Please sign in to comment.