fix: create output dir (if not exists) for gen_completions command#3519
fix: create output dir (if not exists) for gen_completions command#3519inteist wants to merge 2 commits into
gen_completions command#3519Conversation
this follows standard *nix behavior. i.e. if the folder doesn't exist usually in *nix environments in this case, the folder is created automatically. - If the directory already exists, it succeeds and does nothing. - If parent directories are missing, it creates them. - If the path exists but is a file, it returns an error. - If permissions prevent creating/accessing it, it returns an error.
Fossier: Manual Review Requested
Score BreakdownTotal Score: 65.0/100 | Confidence: 100% | Outcome: REVIEW
|
Greptile SummaryThis PR makes completion generation create the requested output directory first. The main changes are:
Confidence Score: 4/5This is close, but the directory mode issue should be fixed before merging.
Important Files Changed
Reviews (1): Last reviewed commit: "fix: create output dir (if not exists) f..." | Re-trigger Greptile |
|
|
||
| match out_dir { | ||
| Some(out_dir) => { | ||
| fs_err::create_dir_all(&out_dir)?; |
There was a problem hiding this comment.
Creates private completion dirs
AtuinCmd::run sets the process umask to 077 before dispatching commands. With this new create_dir_all, atuin gen-completions --out-dir /usr/local/share/bash-completion/completions can create missing shared completion directories as 0700 when run under sudo, so normal users cannot traverse them and shell completion loading breaks.
There was a problem hiding this comment.
Hmmm...
The use case seems a little forced to me.
Most use cases would be to generate completions to STDOUT
We generate completions into a folder to then move it. So IMO this is a non issue.
potential adjustment would be
adding if !matches!(&self, Self::GenCompletions(_)) {
into
impl AtuinCmd {
pub fn run(self) -> Result<()> {
#[cfg(not(windows))]
if !matches!(&self, Self::GenCompletions(_)) {this needs to be reviewed by someone who better understands various use cases for this.
this follows standard *nix behavior. i.e. if the folder doesn't exist usually in *nix environments in this case, the folder is created automatically.
Checks