-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved log messages that contain a directory path #36
Conversation
When logging a message about archive creation it was formatted with a static '/' in front for the directory name. This is fine relative directory paths, but when using a absolute path this will lead to a double '/' being printed. This change only add a '/' in front of the path if there is non. Without this change: input output "/usr/local" -> "//usr/local" "usr/local" -> "/usr/local" With this change: input output "/usr/local" -> "/usr/local" "usr/local" -> "/usr/local"
I'm not sure how to make the CI happy as the tool |
Thanks for this PR, @xanderio! I'm not clear on why you'd need absolute paths. Everything is always relative to |
On Sun, 23. Jun 07:09, Adam Weinberger wrote:
Thanks for this PR, @xanderio!
I'm not clear on why you'd need absolute paths. Everything is always relative to `/`. Can you describe your use case?
I use absolute paths so that the shell will use globs.
For example when creating backups of `/usr/local/etc` for multiple
jails. But the shell glob expansion is only trigger when providing an
absolute path. `/usr/jails/*/usr/local/etc`.
…
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#36 (comment)
|
That's an interesting use case; I hadn't considered that approach before. This sounds like a pretty unique usage though, and I'm not sure this message will have a big impact on other users. To me, this sounds like something that upstream tarsnap might address. Why should (Edit: typo) |
Because the In this case for When using a absolute path the shell can expand the pattern and replace the path with a In case of the program path in the For example amusing this file layout
backuptargets="/home/*" will become backuptargets="/home/user1 /home/user2 /home/user3" |
Ah, I hadn't thought about it being a simple shell expansion. So, you're of course completely correct that, while technically valid, the output is clearly clunky-looking and suboptimal. I'm working a major refactoring that would clobber this patch anyway, so I won't merge the PR right now. I'll do my best to fix this output during the refactor, and I'll ping you here once the branch for it is pushed. In the meantime, some alternatives might also accomplish what you're looking for:
|
We have a couple different ways we need to format strings. Putting everything into one function makes it easy to format strings in ways that look right to our users. This also simplifies the printing of error output, which required shell-check escapes and multiple levels of escaped quotes. It's a bit obtuse to dump all this stuff into one function, but it gives us the most flexibility.
I added the formatter into a single function, so this should be working as you intended now. Please re-open if it doesn't do the right thing. Thanks for submitting this and for your patience, @xanderio. |
When logging a message about archive creation it was formatted with a
static '/' in front for the directory name. This is fine relative
directory paths, but when using a absolute path this will lead to a
double '/' being printed.
This change only add a '/' in front of the path if there is non.
Without this change:
With this change: