diff --git a/__whiledir.cpp b/__whiledir.cpp index d930dc2..3e1730b 100644 --- a/__whiledir.cpp +++ b/__whiledir.cpp @@ -11,21 +11,23 @@ namespace jet { __whiledir::__whiledir(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) { if(!variableDefined("path")) throw coreutils::Exception("whiledir tag must specify a path."); - if(!variableDefined("name")) - throw coreutils::Exception("whiledir tag requires a name tag."); if(variableDefined("sort") && (variables["sort"] == "true")) { std::vector entries; for(auto const &entry : std::filesystem::directory_iterator(variables["path"].str())) entries.push_back(entry); std::sort(entries.begin(), entries.end(), [](const auto &a, const auto &b) { return a.path() < b.path(); }); for(const auto &entry : entries) { - variables[variables["name"]] = entry.path(); + global.variables[variables["fullpath"]] = entry.path(); + global.variables[variables["filename"]] = entry.path().filename(); + global.variables[variables["filenamenoextension"]] = entry.path().stem(); processContainer(container); container.reset(); } } else { for(auto const &entry : std::filesystem::directory_iterator(variables["path"].str())) { - variables[variables["name"]] = entry.path(); + global.variables[variables["fullpath"]] = entry.path(); + global.variables[variables["filename"]] = entry.path().filename(); + global.variables[variables["filenamenoextension"]] = entry.path().stem(); processContainer(container); container.reset(); } diff --git a/jet-2.0 b/jet-2.0 index 459a7e1..e78ac53 100755 Binary files a/jet-2.0 and b/jet-2.0 differ diff --git a/testjet.jet b/testjet.jet index dfcb31b..82a82a7 100755 --- a/testjet.jet +++ b/testjet.jet @@ -55,8 +55,8 @@ $[ls] $[filex] - - #[file] + + $[file] $[fullpath] $[noext]