shx icon indicating copy to clipboard operation
shx copied to clipboard

find not fully supported

Open tdjastrzebski opened this issue 4 years ago • 7 comments

I just made the first attempt to use shx. shx find BUILD/debug -type f -name '*.o' yields find: no such file or directory: -type

tdjastrzebski avatar Mar 26 '20 23:03 tdjastrzebski

This is a known limitation of ShellJS's find() method. First step would be supporting the -type flag over there. I think shx could translate "-name" to shelljs's expected syntax, similar to how we translate sed's syntax:

https://github.com/shelljs/shx/blob/7e7bf7fe136c923ab6abbc39406fb87444aaf16d/src/shx.js#L95-L100

nfischer avatar Mar 27 '20 03:03 nfischer

It looks -name flag is not fully supported as well. shx find BUILD/debug -name '*.o' results in find: no such file or directory: -name

tdjastrzebski avatar Mar 29 '20 00:03 tdjastrzebski

-name is just the default argument. Try cd BUILD/debug && shx find '**/*.o'.

nfischer avatar Mar 30 '20 04:03 nfischer

Well, yes, of course. The point, however, is still valid. -name flag is not supported.

tdjastrzebski avatar Mar 30 '20 10:03 tdjastrzebski

My point above was that we could probably translate that within shx itself (merge default arg + -name into shelljs's expected input). But there's little point for doing so right now because shell.find() is just a wrapper around shell.ls() (you could just use shx ls for the same effect). If we implement -type, then shell.find() would bring something valuable to the table.

nfischer avatar Mar 30 '20 22:03 nfischer

Any update on this? Thanks 😥

carlocorradini avatar Feb 09 '23 12:02 carlocorradini

Sorry for bothering you, but does the following work?

npx shx find "scripts/**/*.sh" -exec npx shellcheck {} \;

Or there is another (supported) approach? Thanks

carlocorradini avatar Feb 09 '23 12:02 carlocorradini