blob: 707036c35bf4429e4c63840246cbbc3ce89ab4b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/sh -e
msg() {
printf '\033[1;31m%s\033[0m\n' "$1"
}
if [ $# = 1 ]; then
# Check if it's an existing file
if [ -r "$1" ]; then
if [ ! -w "$1" ]; then
msg "WARNING!!! File is not writeable: $1"
read -r REPLY
fi
else
# It's a new file, check if the containing directory is writable
dir="$(dirname "$1")"
if [ ! -w "$dir" ]; then
msg "WARNING!!! Can't write in directory: $dir"
read -r REPLY
fi
fi
fi
nano "$@"
|