实用脚本与趣味游戏:Mac OS X 中的脚本应用
1. 修复open命令
1.1open命令存在的问题
Mac OS X 系统中的open命令是一个很棒的创新,它能让我们轻松为各种类型的文件启动合适的 Aqua 应用程序,比如图形图像、PDF 文档,甚至 Excel 电子表格。不过,open命令的行为有点古怪。要是你想通过它启动指定的应用程序,就必须加上-a标志。而且,如果你没有准确指定应用程序的名称,它就会报错并无法执行。
1.2open2脚本代码
#!/bin/sh # open2 - A smart wrapper for the cool Mac OS X 'open' command # to make it even more useful. By default, open launches the # appropriate application for a specified file or directory # based on the Aqua bindings, and has a limited ability to # launch applications if they're in the /Applications dir. # First off, whatever argument we're given, try it directly: