diff --git a/builtin.c b/builtin.c index 7ffa6c9a8..f338d47b9 100644 --- a/builtin.c +++ b/builtin.c @@ -357,7 +357,8 @@ static void builtin_print_help( wchar_t *cmd, string_buffer_t *b ) Several other builtins, including jobs, ulimit and set are so big that they have been given their own file. These files are all named - 'builtin_NAME.c', where NAME is the name of the builtin. + 'builtin_NAME.c', where NAME is the name of the builtin. These files + are included directly below. */ @@ -1507,6 +1508,7 @@ static int builtin_read( wchar_t **argv ) wchar_t *prompt = DEFAULT_READ_PROMPT; wchar_t *commandline = L""; int exit_res=0; + wchar_t *mode_name = READ_MODE_NAME; woptind=0; @@ -1543,6 +1545,10 @@ static int builtin_read( wchar_t **argv ) L"command", required_argument, 0, 'c' } , + { + L"mode-name", required_argument, 0, 'm' + } + , { L"help", no_argument, 0, 'h' } @@ -1557,7 +1563,7 @@ static int builtin_read( wchar_t **argv ) int opt = wgetopt_long( argc, argv, - L"xglUup:c:h", + L"xglUup:c:hm:", long_options, &opt_index ); if( opt == -1 ) @@ -1579,25 +1585,35 @@ static int builtin_read( wchar_t **argv ) case L'x': place |= ENV_EXPORT; break; + case L'g': place |= ENV_GLOBAL; break; + case L'l': place |= ENV_LOCAL; break; + case L'U': place |= ENV_UNIVERSAL; break; + case L'u': place |= ENV_UNEXPORT; break; + case L'p': prompt = woptarg; break; + case L'c': commandline = woptarg; break; + case L'm': + mode_name = woptarg; + break; + case 'h': builtin_print_help( argv[0], sb_out ); return STATUS_BUILTIN_OK; @@ -1668,7 +1684,7 @@ static int builtin_read( wchar_t **argv ) */ if( isatty(0) && builtin_stdin == 0 ) { - reader_push( READ_MODE_NAME ); + reader_push( mode_name ); reader_set_prompt( prompt ); reader_set_buffer( commandline, wcslen( commandline ) ); diff --git a/doc_src/read.txt b/doc_src/read.txt index d9c330671..13e4d658d 100644 --- a/doc_src/read.txt +++ b/doc_src/read.txt @@ -11,6 +11,7 @@ input and store the result in one or more environment variables. - -c CMD or --command=CMD specifies that the initial string in the interactive mode command buffer should be CMD. - -e or --export specifies that the variables will be exported to subshells. - -g or --global specifies that the variables will be made global. +- -m NAME or --mode-name=NAME specifies that the name NAME should be used to save/load the hiustory file. If NAME is fish, the regular fish history will be available. - -p PROMPT_CMD or --prompt=PROMPT_CMD specifies that the output of the shell command PROMPT_CMD should be used as the prompt for the interactive mode prompt. The default prompt command is set_color green; echo read; set_color normal; echo "> ". - -u or --unexport causes the specified environment not to be exported to child processes - -U or --universal causes the specified environment variable to be made universal. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell. diff --git a/share/completions/read.fish b/share/completions/read.fish index 880fc1768..1a88aa693 100644 --- a/share/completions/read.fish +++ b/share/completions/read.fish @@ -5,4 +5,4 @@ complete -c read -s g -l global -d (N_ "Make variable scope global") complete -c read -s l -l local -d (N_ "Make variable scope local") complete -c read -s U -l universal -d (N_ "Make variable scope universal, i.e. share variable with all the users fish processes on this computer") complete -c read -s u -l unexport -d (N_ "Do not export variable to subprocess") - +complete -c read -s m -l mode-name -d (N_ "Name to load/save history under") -r -a "read fish"