Skip to content

Commit a574ed3

Browse files
kmykkyuridenamida
authored andcommitted
Make generated files executable when they have shebang (kyuridenamida#138)
1 parent 48880c9 commit a574ed3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

atcodertools/fileutils/create_contest_file.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import stat
23
from typing import List
34

45
from atcodertools.client.models.sample import Sample
@@ -13,6 +14,9 @@ def _make_text_file(file_path, text):
1314
def create_code(source_code: str,
1415
file_path: str):
1516
_make_text_file(file_path, source_code)
17+
if source_code.startswith('#!'):
18+
st = os.stat(file_path)
19+
os.chmod(file_path, st.st_mode | stat.S_IEXEC)
1620

1721

1822
def create_example(example: Sample, in_example_name: str, out_example_name: str):

0 commit comments

Comments
 (0)