Skip to content

Commit 69c87c8

Browse files
committed
Do not install bash completion as non-root
This commit will detect if user runs setup.py as root and it will install the bash completion files only in that case. Note that the warning message about bash completion files not being installed is printed only if the installation is run with -v or --verbose flag. Fixes #37
1 parent 58db8f4 commit 69c87c8

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@
2525
completion_dirs = ['/usr/share/bash-completion/completions',
2626
'/usr/local/opt/bash-completion/etc/bash_completion.d']
2727

28-
for d in completion_dirs:
29-
if os.path.isdir(d):
30-
data_files.append((d, ['contrib/bash-completion/jenkins']))
28+
if os.geteuid() == 0:
29+
for d in completion_dirs:
30+
if os.path.isdir(d):
31+
data_files.append((d, ['contrib/bash-completion/jenkins']))
32+
else:
33+
print("Non-root user detected. Bash completion won't be installed.")
3134

3235
setup(
3336
name='jenkins-cli',

0 commit comments

Comments
 (0)