我有一个看起来像这样的脚本:
function main() {
for source in "$@"; do
sort_imports "${source}"
done
}
main "$@"
现在,如果我传入一个文件 ./myFile.m,脚本会按预期工作。
我想将其更改为传入 ./myClassPackage 并让它找到所有文件并在每个文件上调用 sort_imports。
我试过了:
for source in $(find "$@"); do
sort_imports "${source}"
done
但是当我调用它时,我收到一个错误,我将它传递给一个目录。
如果您不想find
枚举目录,则排除它们:
for source in $(find "$@" -not -type d); do
sort_imports "${source}"
done
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句