nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

nimscript: `cpFile` does not copy executable permissions #18211

Open vitreo12 opened 3 years ago

vitreo12 commented 3 years ago

When running cpFile in nimscript on an executable binary, permissions are not copied over. This makes the copied binary unusable unless chmod +x is run on it afterwards.

Example

test.nims

cpFile(getCurrentDir() & "/someBinary", getCurrentDir() & "/someBinary1")
nim test.nims

Current Output

./someBinary1 is not executable, ./someBinary is. Permissions differ: ./someBinary1 does not have executable permissions. chmod +x ./someBinary1 fixes it.

Expected Output

./someBinary1 should have executable permissions, since ./someBinary had them.

Nim Compiler Version 1.4.8 [Linux: amd64]
Compiled at 2021-05-25
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 44e653a9314e1b8503f0fa4a8a34c3380b26fff3
active boot switches: -d:release
vitreo12 commented 3 years ago

Additionally, I've tried to use the setFilePermissions proc from os.nim, but apparently it is not available for NimScript.