vsh: Allow non-interactive use of 'cd' command

For testing purposes it will come handy to change the directory from a
batch-mode script. Remove the check forbidding use of the 'cd' command
in batch mode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2024-03-21 14:46:29 +01:00
parent 6193c4656e
commit eb82c632e3
2 changed files with 0 additions and 7 deletions

View File

@ -326,8 +326,6 @@ Will change current directory to *directory*. The default directory
for the ``cd`` command is the home directory or, if there is no *HOME* for the ``cd`` command is the home directory or, if there is no *HOME*
variable in the environment, the root directory. variable in the environment, the root directory.
This command is only available in interactive mode.
pwd pwd
--- ---

View File

@ -3207,11 +3207,6 @@ cmdCd(vshControl *ctl, const vshCmd *cmd)
const char *dir = NULL; const char *dir = NULL;
g_autofree char *dir_malloced = NULL; g_autofree char *dir_malloced = NULL;
if (!ctl->imode) {
vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
return false;
}
if (vshCommandOptStringQuiet(ctl, cmd, "dir", &dir) <= 0) if (vshCommandOptStringQuiet(ctl, cmd, "dir", &dir) <= 0)
dir = dir_malloced = virGetUserDirectory(); dir = dir_malloced = virGetUserDirectory();
if (!dir) if (!dir)