don't die if read is invoked with no var names

Partial fix for #4220 by restoring the old behavior if no var name was
provided. But we still set an empty var if a var name was provided.
This commit is contained in:
Kurtis Rader 2017-07-16 21:43:00 -07:00
parent 8f22def8f7
commit 71af1a9566

View File

@ -398,7 +398,9 @@ int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
if (optind == argc || exit_res != STATUS_CMD_OK) {
// Define the var without any data. We do this because when this happens we want the user to
// be able to use the var but have it expand to nothing.
env_set(argv[optind], NULL, opts.place);
//
// TODO: For fish 3.0 we should mandate at least one var name.
if (argv[optind]) env_set(argv[optind], NULL, opts.place);
return exit_res;
}