-
Notifications
You must be signed in to change notification settings - Fork 30
/
shell_utils.sh
executable file
·49 lines (43 loc) · 2.09 KB
/
shell_utils.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# **************************************************************************** #
# #
# ::: :::::::: #
# shell_utils.sh :+: :+: :+: #
# +:+ +:+ +:+ #
# By: aguiot-- <aguiot--@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/11/29 17:03:39 by aguiot-- #+# #+# #
# Updated: 2021/04/11 16:15:38 by aguiot-- ### ########.fr #
# #
# **************************************************************************** #
################################################################################
# Valgrind in docker with custom compilation command
# Usage: valgrind_docker_custom "make re" "./ft_ls -l /tmp ~"
function valgrind_docker_custom () {
docker run -it --rm --workdir "$HOME" --entrypoint sh -v "$PWD:$HOME" mooreryan/valgrind -c "$1 && valgrind --leak-check=full --track-origins=yes --show-leak-kinds=all --show-reachable=yes $2"
}
# Valgrind in docker with default make
# Usage: valgrind_docker_make ./ft_ls -l /tmp ~
function valgrind_docker_make () {
valgrind_docker_custom "make" "$*"
}
# Valgrind on macOS with fsanitize protection
# Usage: valgrind_macos ./ft_ls -l /tmp ~
# You must use "./" to specify executable file
function valgrind_macos ()
{
local i
for i in "$@"; do
if [[ $i == ./* ]]; then
cmd=$(nm -an $i | grep asan)
if [[ $? == 0 ]]; then
echo -e "\033[0;91mYou are trying to run valgrind but you compiled with -fsanitize. \033[1;31mNEVER do this on macOS\033[0;91m, this will crash you computer.\033[0;39m"
else
command valgrind $*
fi
break
fi
done
}
# Default alias on valgrind_macos
alias valgrind='valgrind_macos'
################################################################################