Set the correct permissions on the zshenv (#257)

* Set the correct permissions on the zshenv

* Update error to suggest chmod instead of delete

* Missed a formatting option

* 644, not 755

* Get a bit more specific

* Mac specific permissions
This commit is contained in:
Ana Hobden 2023-02-21 07:28:14 -08:00 committed by GitHub
parent 5582d050fc
commit 7e951a5b6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,7 @@ use crate::action::{Action, ActionDescription, ActionError, StatefulAction};
use nix::unistd::User;
use std::path::{Path, PathBuf};
use target_lexicon::OperatingSystem;
use tokio::task::JoinSet;
use tracing::{span, Instrument, Span};
@ -65,12 +66,22 @@ impl ConfigureShellProfile {
);
continue;
}
// Macs require a different mode on certain files...
let required_mode = match target_lexicon::OperatingSystem::host() {
OperatingSystem::MacOSX {
major: _,
minor: _,
patch: _,
}
| OperatingSystem::Darwin => 0o100444,
_ => 0o100644,
};
create_or_insert_files.push(
CreateOrInsertIntoFile::plan(
profile_target_path,
None,
None,
None,
required_mode,
shell_buf.to_string(),
create_or_insert_into_file::Position::Beginning,
)
@ -112,7 +123,7 @@ impl ConfigureShellProfile {
profile_target,
None,
None,
0o0755,
0o100644,
fish_buf.to_string(),
create_or_insert_into_file::Position::Beginning,
)