duckscript
                                
                                
                                
                                    duckscript copied to clipboard
                            
                            
                            
                        --recursive flag for some `fs` commands
Feature Description
Sometimes it can be quite useful to operate not only on a directory but also all subdirs. Therefore, I'd like an easy way to get all files in a file tree or compare if any file in one dir is newer than another path.
Describe The Solution You'd Like
a recursive flag for commands like ls or is_path_newer.
For ls the behavior is easily defined: just print all files of any subpath.
For is_path_newer there are technically 3 different possible behaviors:
- recursive only the one that should be newer
 - recursive only the one that should be older
 - recursive for both.
 
For my use case, any of these would be fine (I just want to know if any file in the src dir is newer than the build dir), but they could also be made available as 2-3 different flags:
- recursive-left
 - recursive-right
 - (recursive-both)
 
There are probably other commands that would benefit from this as well.
not sure i want to have recursive on everything. where it makes more sense like copy/move/remove ya, but is path newer feels a bit strange. how about using the glob command?
handle = glob_array ./somedir/**/*.txt
for path in ${handle}
    echo ${path}
end
                                    
                                    
                                    
                                
how about using the glob command?
That would still result in a bit of a mouthful:
target = glob_array build/**/*
src = glob_array src/**/*
any_newer = false
for src_file in ${src}
    for target_file in ${target}
        if is_path_newer ${src_file} ${target_file}
            any_newer = true
        end
    end
end
if ${any_newer}
    # My actual behaviour
end
But in the end all I would personally need is https://github.com/sagiegurari/cargo-make/issues/611#issuecomment-1053675206
your code is wrong. you don't need to walk and glob both source and target. only source. that makes the code half the size.
your code is wrong. you don't need to walk and glob both source and target. only source. that makes the code half the size.
Depends on whether the target folder gets touched with every build, but that is probably true in most cases.
but you are comparing EVERY source file with EVERY target file. thats wrong. no way you need to do that. you have src/file1.src src/file2.src target/file1.bin target/file2.bin
if you glob on both and compare all, why would comparing src/file.src with target/file2.bin will help? file1 and file2 are unrelated.
if you glob on both and compare all, why would comparing src/file.src with target/file2.bin will help? file1 and file2 are unrelated.
Depends on your language if there is a one to one mapping of build artifacts to src files
again, based on source you create the target files to check. you don't glob. and i think there is no way that every source file needs to be checked against every target file. so is newer onglobs makes, at the moment, little sense to me. give me one use case please.
and i think there is no way that every source file needs to be checked against every target file.
That is probably true, but I'd rather take the cost of comparing every file with every file than actually figuring out the exact mapping, that's also why https://github.com/sagiegurari/cargo-make/issues/611#issuecomment-1053675206 would be sufficient for my use.
Probably a better way to do it would be iterating over both folders and just take the highest timestamp, tho.