diff --git a/command.cpp b/command.cpp index a89a120..d95d6c2 100644 --- a/command.cpp +++ b/command.cpp @@ -26,6 +26,12 @@ #include #include + + +#if defined(__APPLE__) +#include +#endif + extern std::atomic control_c; namespace fs = filesystem; @@ -107,8 +113,22 @@ namespace { } + bool is_script(const fs::path &path) { - return path.extension() == ".text"; + + #if defined(__APPLE__) + /* check for a file type of TEXT */ + + uint8_t finfo[32]; + int ok = getxattr(path.c_str(), XATTR_FINDERINFO_NAME,finfo, sizeof(finfo), 0, 0); + if (ok < 4) return false; + + if (memcmp(finfo, "TEXT", 4) == 0) return true; + return false; + + #else + return path.extension() == ".script"; + #endif } }