set: Print an error when setting umask to a bad value

Repurpose the ENV_INVALID return value for env_set(), which wasn't
currently used by anything. When a bad value is passed for the 'umask'
key, return ENV_INVALID to signal this and print a good error message
from the `set` builtin.

This makes `set umask foo` properly produce an error.
This commit is contained in:
Kevin Ballard
2014-07-13 19:08:15 -07:00
committed by ridiculousfish
parent d0c85471b4
commit 9f725bee1f
3 changed files with 6 additions and 4 deletions

View File

@@ -655,10 +655,12 @@ int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t var_mode)
if (!errno && (!*end) && (mask <= 0777) && (mask >= 0))
{
umask(mask);
/* Do not actually create a umask variable, on env_get, it will be calculated dynamically */
return 0;
}
}
/* Do not actually create a umask variable, on env_get, it will be calculated dynamically */
return 0;
return ENV_INVALID;
}
/*