-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCompiler.sh
More file actions
63 lines (52 loc) Β· 1.79 KB
/
Compiler.sh
File metadata and controls
63 lines (52 loc) Β· 1.79 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/data/data/com.termux/files/usr/bin/bash
# Colors
RED="\e[31m"
GREEN="\e[32m"
CYAN="\e[36m"
YELLOW="\e[33m"
RESET="\e[0m"
# ASCII Banner
clear
echo -e "${CYAN}"
echo ' βββββββββββ βββ βββββββ '
echo ' βββββββββββ βββββββββββ '
echo ' βββββββββββββββββββMSI-Sirajul '
echo ' βββββββββββββββββββv.1.2 '
echo ' βββββββββββ βββββββββββ '
echo ' βββββββββββ βββ βββββββ '
echo -e "${YELLOW}Β©msi${RESET}"
echo ""
# Prompt for the file to compile
echo -e "${GREEN}[?]Enter File Directory${RESET}"
read -p ": " filepath
# Check if file exists
if [ ! -f "$filepath" ]; then
echo -e "${RED}[β] File not found! Try again.${RESET}"
exit 1
fi
# Define correct Termux shebang
termux_shebang="#!/data/data/com.termux/files/usr/bin/bash"
# Read first line of the file
first_line=$(head -n 1 "$filepath")
# Insert shebang if missing
if [[ "$first_line" != "$termux_shebang" ]]; then
echo -e "${YELLOW}[*] Adding correct shebang to the script...${RESET}"
tmpfile=$(mktemp)
echo "$termux_shebang" > "$tmpfile"
cat "$filepath" >> "$tmpfile"
mv "$tmpfile" "$filepath"
fi
# Extract filename without extension
filename=$(basename "$filepath" .sh)
# Compile using shc with custom output
echo -e "${CYAN}[*] Compiling '$filename' ...${RESET}"
shc -f "$filepath" -o "$filename"
# Remove unnecessary file
rm -f "${filepath}.x.c"
# Check if compiled file exists
if [ -f "$filename" ]; then
echo -e "${GREEN}[β] Compilation complete!${RESET}"
echo -e "${YELLOW}Output file: ${filename}${RESET}"
else
echo -e "${RED}[β] Compilation failed.${RESET}"
fi