Skip to content

Conversation

themobiusproject
Copy link

@themobiusproject themobiusproject commented Jun 9, 2020

Remove executable flag from json, swift, c, h, m files
Add executable flag to pl, py, r, rb files

Resolves #87

Remove flag from json, swift, c, h, m files
Add flag to pl, py, r, rb files
@cebtenzzre
Copy link

This is close, but there are still a few discrepancies. This command:

find . -type f -executable \! \( -exec bash -c 'case $(file -b --mime-type -- "$1") in application/x-mach-binary) ;& application/x-executable) ;& application/x-pie-executable) exit 0 ;; esac; exit 1' _ {} \; -o -exec cmp -sn2 -- =(<<<'#!') {} \; \) -printf '%P\n'

shows a few files that are still marked executable, but should not be:

parsers/test_Json.NET/Program.cs
parsers/test_Json.NET/bin/Release/netcoreapp1.0/publish/Newtonsoft.Json.dll
parsers/test_Json.NET/bin/Release/netcoreapp1.0/publish/System.Runtime.Serialization.Primitives.dll
parsers/test_Json.NET/bin/Release/netcoreapp1.0/publish/test_Json.NET.dll
parsers/test_Json.NET/bin/Release/netcoreapp1.0/publish/test_Json.NET.pdb
parsers/test_Squeak_JSON_tonyg/Squeak.app/Contents/Resources/SqueakChanges.icns
parsers/test_Squeak_JSON_tonyg/Squeak.app/Contents/Resources/SqueakGeneric.icns
parsers/test_Squeak_JSON_tonyg/Squeak.app/Contents/Resources/SqueakImage.icns
parsers/test_Squeak_JSON_tonyg/Squeak.app/Contents/Resources/SqueakPlugin.icns
parsers/test_Squeak_JSON_tonyg/Squeak.app/Contents/Resources/SqueakProject.icns
parsers/test_Squeak_JSON_tonyg/Squeak.app/Contents/Resources/SqueakScript.icns
parsers/test_Squeak_JSON_tonyg/Squeak.app/Contents/Resources/SqueakSources.icns
parsers/test_java_jackson_2_8_4/jackson-annotations-2.2.3.jar
parsers/test_json.cr
parsers/test_json.php
parsers/test_json_re.rb

That list includes a ruby script that does not have a shebang line. Adding a shebang would make its execute bit reasonable.

If the "not" operator is moved from after -executable to before it, the command shows that these files are still not marked executable, but technically should be:

parsers/test_ObjCNSJSONSerializer/test_ObjCNSJSONSerializer/a.out.dSYM/Contents/Resources/DWARF/a.out
parsers/test_ccan_json/json/_test/x.py
parsers/test_json-rust/target/debug/tj.dSYM/Contents/Resources/DWARF/tj
parsers/test_json-rustc_serialize/rj/target/debug/rj.dSYM/Contents/Resources/DWARF/rj

Though if the binaries in that list (everything except for x.py) have never been executed, does having the execute bit set really matter?

@themobiusproject
Copy link
Author

That is more bash that I normally string together. But your command is also giving me an error of -bash: syntax error near unexpected token '('.

I personally try to keep executable files with their executable flag set even though it is just about as easy to type bash bashfile.sh. I will chmod the files listed above and leave it there.

@cebtenzzre
Copy link

@themobiusproject Sorry, I use zsh and I've gotten so used to it that I sometimes forget which features are standard. In bash you can substitute =(<<<'#!') with the path to a file with the contents #! (newline is optional).

@themobiusproject
Copy link
Author

@cebtenzzre Thank you for the bash fix and I am glad that my comment could clue you in to the problem. I am going to dissect that command a bit and try to add pieces to my repertoire.

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

Successfully merging this pull request may close these issues.

Executable bit set on non-executable files

2 participants