Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ INTERPRETER_CORPUS/*
.idea/*
src/ttyio
src/ttyio/*
acceptance_tests/ncsh_history
acceptance_tests/ncsh_history_test
acceptance_tests/_z_database.bin
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ Please see COMPILE.md.
* More rc file configurations
* More compile-time configurations
* Frecency-based autocomplete
* More built-in commands like export, setting environment variables, etc.
* Custom prompt colors, backgrounds
* Improve noninteractive mode
* Add command-line flags for noninteractive mode
* Better POSIX compliance
* Usable with GDB (currently doesn't work)
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// clang-format off

#define NCSH_VERSION "0.0.7.0"
#define NCSH_VERSION "0.0.8.1"

/* EXIT_* Constants
* Exit values used by a multitude of functions and areas in the shell.
Expand Down
20 changes: 9 additions & 11 deletions src/interpreter/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,8 @@ static int builtins_enable(Str* restrict strs)
#define PROMPT_OPTION_NONE "ncsh prompt: please pass in at least one option:\n" \
"--user (-u): false, true\n" \
"--type (-t): short, normal, none, fish"
#define PROMPT_OPTION_NOT_SUPPORTED "ncsh prompt: unsupported option."
#define PROMPT_USER_OPTION_NOT_SUPPORTED "ncsh prompt: unsupported option for user."
#define PROMPT_TYPE_OPTION_NOT_SUPPORTED "ncsh prompt: unsupported option for type."
#define PROMPT_OPTION_NO_VALUE "ncsh prompt: no value found for option."
[[nodiscard]]
static int builtins_prompt(Str* restrict strs)
Expand Down Expand Up @@ -844,15 +845,13 @@ static int builtins_prompt(Str* restrict strs)
return EXIT_SUCCESS;
}

if (prompt_dir_type_set(*args)) {
if (builtins_writeln(vm_output_fd, PROMPT_OPTION_NOT_SUPPORTED,
sizeof(PROMPT_OPTION_NOT_SUPPORTED) - 1) == -1) {
if (prompt_dir_type_set(*args) != EXIT_SUCCESS) {
if (builtins_writeln(vm_output_fd, PROMPT_TYPE_OPTION_NOT_SUPPORTED,
sizeof(PROMPT_TYPE_OPTION_NOT_SUPPORTED) - 1) == -1) {
return EXIT_FAILURE;
}
return EXIT_FAILURE_CONTINUE;
}
++args;
continue;
}

if (estrcmp(*args, Str_Lit(NCSH_PROMPT_USER)) || estrcmp(*args, Str_Lit(NCSH_PROMPT_USER_SHORT))) {
Expand All @@ -865,16 +864,15 @@ static int builtins_prompt(Str* restrict strs)
return EXIT_SUCCESS;
}

if (prompt_show_user_set(*args)) {
if (builtins_writeln(vm_output_fd, PROMPT_OPTION_NOT_SUPPORTED,
sizeof(PROMPT_OPTION_NOT_SUPPORTED) - 1) == -1) {
if (prompt_show_user_set(*args) != EXIT_SUCCESS) {
if (builtins_writeln(vm_output_fd, PROMPT_USER_OPTION_NOT_SUPPORTED,
sizeof(PROMPT_USER_OPTION_NOT_SUPPORTED) - 1) == -1) {
return EXIT_FAILURE;
}
return EXIT_FAILURE_CONTINUE;
}
++args;
continue;
}
++args;
}

return EXIT_SUCCESS;
Expand Down
4 changes: 3 additions & 1 deletion src/interpreter/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,8 +890,10 @@ static Parser_Internal parse_token(Parser_Data* restrict data, Lexemes* restrict
}

case T_DOLLAR: {
if (is_in_quotes())
if (is_in_quotes()) {
const_op = OP_STR_EXPANSION;
goto quoted;
}

peeked = peek(lexemes, *i + 1);
if (peeked == T_CONST) {
Expand Down
1 change: 1 addition & 0 deletions src/interpreter/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum Ops : uint8_t {
OP_ASSIGNMENT, // (var=val)
OP_HOME_EXPANSION, // ~
OP_GLOB_EXPANSION, // * or ?
OP_STR_EXPANSION, // "file: $file"

OP_JUMP,
OP_JUMP_IF_FALSE,
Expand Down
2 changes: 1 addition & 1 deletion src/io/prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ int prompt_show_user_set(Str show_user)
prompt_data.show_user = false;
return EXIT_SUCCESS;
}
return EXIT_SUCCESS;
return EXIT_FAILURE_CONTINUE;
}

void prompt_init()
Expand Down