mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Allow the user to specify name of history file to use with the read builtin
darcs-hash:20070106142430-ac50b-32ad52077e11438799b17911dc83e57f89e02f2b.gz
This commit is contained in:
parent
7e350dab66
commit
3b4bacb5ba
3 changed files with 21 additions and 4 deletions
22
builtin.c
22
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 ) );
|
||||
|
|
|
@ -11,6 +11,7 @@ input and store the result in one or more environment variables.
|
|||
- <tt>-c CMD</tt> or <tt>--command=CMD</tt> specifies that the initial string in the interactive mode command buffer should be CMD.
|
||||
- <tt>-e</tt> or <tt>--export</tt> specifies that the variables will be exported to subshells.
|
||||
- <tt>-g</tt> or <tt>--global</tt> specifies that the variables will be made global.
|
||||
- <tt>-m NAME</tt> or <tt>--mode-name=NAME</tt> 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.
|
||||
- <tt>-p PROMPT_CMD</tt> or <tt>--prompt=PROMPT_CMD</tt> 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 <tt>set_color green; echo read; set_color normal; echo "> "</tt>.
|
||||
- <code>-u</code> or <code>--unexport</code> causes the specified environment not to be exported to child processes
|
||||
- <code>-U</code> or <code>--universal</code> 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.
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue