Skip to content

Commit f745a8e

Browse files
author
Magne Hov
committed
Make malloc_free_check installable to .local/bin
1 parent 1e300a0 commit f745a8e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

malloc_free_check/install.py

+20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
import pathlib
22

33

4+
def maybe_install_script(script_path: pathlib.Path, script_name: str) -> None:
5+
"""
6+
Ask for permission and then install a script into ~/.local/bin.
7+
"""
8+
local_bin = pathlib.Path.home() / ".local" / "bin"
9+
install_path = local_bin / script_name
10+
11+
choice = input(f"Do you want to install {script_name} to {local_bin}? [y/N] ")
12+
if choice.lower() not in ("y", "yes"):
13+
return
14+
15+
try:
16+
install_path.symlink_to(script_path)
17+
install_path.chmod(0o755)
18+
except OSError as e:
19+
print(f"Failed to install the script: {e}")
20+
21+
422
script = pathlib.Path(__file__).resolve().parent / "malloc_free_check.py"
523

624
print(
@@ -10,3 +28,5 @@
1028
$ {script} <recording-file>
1129
"""
1230
)
31+
32+
maybe_install_script(script, "malloc-free-check")

0 commit comments

Comments
 (0)