git ls-files output does not work in pipeline
Question
I want to remove gitignored files using xargs replacement in nu ($in variable) here's what i wrote
Bash:
git ls-files -i -c --exclude-from=.gitignore | xargs git rm --cached
Nushell:
git ls-files -i -c --exclude-from=.gitignore | git rm --cached $in
However what I notice is that git ls-files does not provide a viable semantics of an array for nushell so it simply treats all files returned by ls-files as one big string with \n as delimiter. I can be wrong. What is my mistake here?
Additional context and details
Possible output:
fatal: pathspec 'dummy/path/file1.txt
dummy/path/file2.txt
dummy/path/file3.txt
dummy/path/file4.txt
dummy/path/file5.txt
' did not match any files
One way of making the output of an external command into a list is to pipe it through the lines command.
git ls-files | lines
I'm guessing to do the next part of the pipeline you'll probably have to pipe those results through | each {|r| git rm --cached $r} or something similar.
@fdncred Yeah that seems like a neat solution, thank you)