Skip to content
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

tmignore list is difficult for other programs to parse #17

Open
nopdotcom opened this issue Mar 30, 2021 · 0 comments
Open

tmignore list is difficult for other programs to parse #17

nopdotcom opened this issue Mar 30, 2021 · 0 comments

Comments

@nopdotcom
Copy link

Summary: tmignore list is hard for other programs to parse. It would be awesome if tmignore list -0 would print just an ASCII NUL-separated list.


When I run tmignore list I get:

119 files/directories have been excluded from backups by tmignore:

  - /Users/nop/gh/project1/DerivedData/
  - /Users/nop/gh/project1/project1.xcodeproj/project.xcworkspace/xcuserdata/
[...]

I wanted to see how much space I was saving.

$ tmignore list | awk '/ - \// {print $3}' | xargs du -hsc
du: /Users/nop/gh/project1/DerivedData/\033[0;39m: No such file or directory
du: /Users/nop/gh/project1/project1.xcodeproj/project.xcworkspace/xcuserdata/[0;39m: No such file or directory
[...]

tmignore is emitting some kind of ANSI terminal code at the end of each line. That's rude if stdout isn't a terminal.

A more-working awk one-liner is:

$ tmignore list | awk -F$"( |\033)" '/ - \// {print $5}' | xargs du -hsc

Ideally, tmignore list -0 (or some other command) would produce a list of files separated by ASCII NUL characters, '\0'. The find, grep, and xargs commands support NUL-separated lists of files. (I really wish POSIX would prohibit filenames with newlines in them; as it is, only / and \0 are the only characters prohibited in filenames.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant