I am developing a shell script. Since I want to use the same version on all my Macs, I have saved it in ~/Dropbox/ and issued chmod 755. However, the ‘execute’ bit keeps getting dropped off when it syncs.
to which I was told:
Dropbox doesn’t actually track most extended attributes for any operating system, the file comes down as a standard read/writeable file. The problem here is that the “file system” on the cloud isn’t ntfs, or ext3, or zfs, or hfs +, so there is no analogous part to the execute bit. or file permissions or any of that extra stuff, but all your bits are there. But OS X supports ACLs that you can set on a directory so that all files created there inherit the same permissions, so drop your script into a folder, and set an ACL for it.
Now I’ve heard of ACLs, but since I’m the only user on my computer, I’ve never actually used them before.
Like most geeks I know, I only really learn about something when I have some practical reason to know it. When people ask me how I know so much about computers, I always tell them “practice” and it’s true.
I don’t sit around reading about something, and if there’s something I just have a casual interest in learning (*cough*perl, emacs, vi*cough*) I probably won’t learn about it even if I do read about it.
Now I had a reason, so I set off to learn something about ACLs.
And here is what I learned about ACLs: they’re fairly complicated for what I’m trying to do.
Here’s another thing about me and (I believe) most geeks: we’re lazy. By which I mean, we’ll accept any acceptable solution, and tend to prefer the first one that “just works”.
(Look at the GUI for most large free software packages, and you’ll understand what I mean. Most geeks don’t care so much about making things pretty as making things work. When things work, they go on to making something else work.)
So, since I didn’t wake up today and say “Hey, I want to learn about ACLs today!” and I don’t know that I’ll have much use to know about them in the future, I went for the easiest solution I could think of, which is this:
chmod -R 755 ~/Dropbox/bin/
which says “Make everything inside the ~/Dropbox/bin/ folder executable.”
And I put that line in my ~/.zshenv, so that whenever I open a new shell, the command gets run. Sure if I had thousands and thousands of files in there, it might be slow, but there 205, and it takes almost no ‘time’ at all:
$ time chmod -R 755 ~/Dropbox/bin
chmod -R 755 ~/Dropbox/bin 0.00s user 0.00s system 16% cpu 0.019 total
Or, to put it another way:
$ date;chmod -R 755 ~/Dropbox/bin;date
Wed Dec 3 23:20:24 EST 2008
Wed Dec 3 23:20:25 EST 2008
It takes less than a second.
Note: because I am a hardcore, comment-happy geek, this is actually what I put in my .zshenv:
# if the folder is found
# make everything inside it executable
# since Dropbox doesn't save execute bit
if [[ -d $HOME/Dropbox/bin ]]
chmod -R 755 $HOME/Dropbox/bin
which means that the command only gets run if the folder is located.
All in all, a pretty dang slick.
Just One More Thing
Did I mention that Dropbox saves revisions?
Yeah, so now if I make a change to a script and decide I want to undo that, I can go back and get a previous version.
Oh, and about those ACLs
15 Geek Cred points to anyone who can tell me the proper ‘chmod’ command to set ~/Dropbox/bin/ so that all the files inside of it are automatically set to be executable.
25 Geek Cred points to anyone who can point me to an online “ACLs in Plain English” explanation (and no, ‘man acl’ doesn’t count :-)
If you want to deal with ACLs in Mac OS X and would like a GUI tool, checkout TinkerTool System (not to be confused with TinkerTool by the same company) which handles ACLs. It sells for € 7.00 (as of 2008-12-03).