minor bash/pwsh output changes

- bash now uses a heredoc to ensure that cheeky filenames containing linebreaks don't escape the echo string
- powershell rename-item now has the verbose flag that i didn't know existed
- there is now a newline between the error and successful output lines
This commit is contained in:
Lynne Megido 2021-06-18 17:42:16 +10:00
parent 4f78d93975
commit e511d215be
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90

View File

@ -167,6 +167,12 @@ pub trait Format {
}
}
if findings.len() != entries.len() {
// if these lengths aren't the same, there was at least one error
// add a blank line between the errors and commands
smart_write(f, writables![Newline])?;
}
for finding in findings {
if let Some(ext) = finding.recommended_extension() {
self.rename(f, finding.file.as_path(), &finding.file.with_extension(ext.as_str()))?;
@ -190,7 +196,7 @@ impl Format for Shell {
}
fn no_known_extension<W: Write>(&self, f: &mut W, path: &Path) -> io::Result<()> {
smart_write(f, writablesln!["echo No known extension for ", path])
smart_write(f, writablesln!["cat <<- '???'", Newline, "No known extension for ", path, Newline, "???"])
}
fn unreadable<W: Write>(&self, f: &mut W, path: &Path) -> io::Result<()> {
@ -233,7 +239,7 @@ impl Format for PowerShell {
// there doesn't seem to be a way to rename the file, prompting only if the target already exists.
smart_write(
f,
writablesln!["Rename-Item -Path ", from, " -NewName ", (to.file_name().unwrap())],
writablesln!["Rename-Item -Verbose -Path ", from, " -NewName ", (to.file_name().unwrap())],
)
}