-
-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[test/spec] Split history builtin tests from builtins2 tests #1593
Conversation
1f8eb99
to
51365de
Compare
osh/builtin_lib.py
Outdated
history_filename = self.GetHistoryFilename() | ||
history_file_exists = path_stat.exists(history_filename) | ||
if not history_file_exists: | ||
raise error.ErrExit(1, "The file '%s' ($HISTFILE) does not exist" % history_filename, loc.Missing()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm actually ErrExit
is intended for use with set -o errexit
I think simply return 1
will do what you want here?
Also I would just say if not path_stat.exists()
instead of the extra var
Is this intended to be friendlier than bash? I think bash just ignores the error?
I tried bash -i -c 'HISTFILE=a; history -r
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I still want to provide some information about the failure. I see that we use a self.errfmt.Print_
pattern in other builtins. Would that be appropriate here?
Is this intended to be friendlier than bash? I think bash just ignores the error?
I tried bash -i -c 'HISTFILE=a; history -r
I do get an error code on my machine (no message though)
$ HISTFILE=_tmp/dne
$ history -r
$ echo $?
1
Ah OK , makes sense. Yes I changed the error message to use In the C++ runtime we have a format string implementation that supports
|
Merged, thanks for doing this! |
As per #1587 (comment).
While working on this I realized we were missing the case where
HISTFILE
does not point to a file (even if it's a valid string). This should return an error code if a user tries to thenhistory -r
.