summaryrefslogtreecommitdiff
path: root/src/job.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-10-17 18:51:52 +0200
committerBram Moolenaar <Bram@vim.org>2020-10-17 18:51:52 +0200
commit218450ad5ea1f9f033b06754a29502d86100ff65 (patch)
treef66cdd5e4ed2cf2b58a3e0143093ad5c3e9f62eb /src/job.c
parent9668cc57a1e70c99163f90f58202e206d12f40c8 (diff)
downloadvim-git-218450ad5ea1f9f033b06754a29502d86100ff65.tar.gz
patch 8.2.1857: Vim9: using job_status() on an unused var gives an errorv8.2.1857
Problem: Vim9: using job_status() on an unused var gives an error. Solution: Return "fail". (closes #7158)
Diffstat (limited to 'src/job.c')
-rw-r--r--src/job.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/job.c b/src/job.c
index f55a8cd81..5876c28cb 100644
--- a/src/job.c
+++ b/src/job.c
@@ -1894,12 +1894,21 @@ f_job_start(typval_T *argvars, typval_T *rettv)
void
f_job_status(typval_T *argvars, typval_T *rettv)
{
- job_T *job = get_job_arg(&argvars[0]);
-
- if (job != NULL)
+ if (argvars[0].v_type == VAR_JOB && argvars[0].vval.v_job == NULL)
{
+ // A job that never started returns "fail".
rettv->v_type = VAR_STRING;
- rettv->vval.v_string = vim_strsave((char_u *)job_status(job));
+ rettv->vval.v_string = vim_strsave((char_u *)"fail");
+ }
+ else
+ {
+ job_T *job = get_job_arg(&argvars[0]);
+
+ if (job != NULL)
+ {
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = vim_strsave((char_u *)job_status(job));
+ }
}
}