1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-06-26 01:07:11 -07:00
rc/sh/e

18 lines
422 B
Plaintext
Raw Normal View History

2013-06-28 05:22:14 -07:00
#!/bin/zsh
# http://unix.stackexchange.com/a/37887
#[ -n "${ZSH_VERSION:-}" ] && local -A EDITOR ${=EDITOR}
# TODO: find actually working way of portably splitting word cmds, zsh/bash
if [ $# -eq 0 ]; then
$=EDITOR
return
fi
2015-03-06 07:14:33 -08:00
local f needroot=0
2013-06-28 05:22:14 -07:00
for f in $@; do
[ -e "$f" ] && { [ -w "$f" ] || needroot=1; }
# TODO: check directory permissions too
done
if [ $needroot -eq 0 ]; then $=EDITOR $@; else sudo -e $@; fi