Added better write permission handling for .python_history
This commit is contained in:
parent
b23402b183
commit
96820cea3e
10
Lib/site.py
10
Lib/site.py
|
@ -448,6 +448,16 @@ def enablerlcompleter():
|
||||||
# home directory does not exist or is not writable
|
# home directory does not exist or is not writable
|
||||||
# https://bugs.python.org/issue19891
|
# https://bugs.python.org/issue19891
|
||||||
pass
|
pass
|
||||||
|
except OSError:
|
||||||
|
if sys.platform == "linux" and not os.access(history, os.W_OK):
|
||||||
|
if os.getuid() == 0:
|
||||||
|
chattrcmd = "chattr -i " + history
|
||||||
|
os.system(chattrcmd)
|
||||||
|
else
|
||||||
|
chattrmsg = "Permission error!, try running 'chattr -i " + history + "'"
|
||||||
|
print(chattrmsg)
|
||||||
|
else
|
||||||
|
print("An error occured while writing to .python_history")
|
||||||
|
|
||||||
atexit.register(write_history)
|
atexit.register(write_history)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue