Skip to content

dfind --exec doesn't handle spaces in filenames #311

@kcgthb

Description

@kcgthb

Filenames containing spaces are not escaped in dfind --exec, which leads to errors.

For instance, given the following file:

$ ls -al /scratch/users/kilian/test/
total 500
drwxr-xr-x  2 kilian ruthm   4096 Nov  8 07:59 .
drwx------ 24 kilian ruthm 507904 Nov  8 07:59 ..
-rw-r--r--  1 kilian ruthm      0 Nov  8 07:59 filename with spaces

dfind --print displays it fine:

$ srun dfind -v --type f --print  /scratch/users/kilian/test/
[2019-11-08T08:03:21] Walking /scratch/users/kilian/test
[2019-11-08T08:03:23] Walked 2 items in 1.449959 seconds (1.379349 files/sec)
/scratch/users/kilian/test/filename with spaces

but dfind --exec fails to find it:

$ srun dfind -v --type f --exec ls -al {} \;  /scratch/users/kilian/test/
[2019-11-08T08:04:17] Walking /scratch/users/kilian/test
[2019-11-08T08:04:19] Walked 2 items in 1.458525 seconds (1.371249 files/sec)
ls: cannot access /scratch/users/kilian/test/filename: No such file or directory
ls: cannot access with: No such file or directory
ls: cannot access spaces: No such file or directory

A workaround is to escape-quote the filepath placeholder {}:

# srun dfind -v --type f --exec ls -al \"{}\" \;  /scratch/users/kilian/test/
[2019-11-08T08:05:13] Walking /scratch/users/kilian/test
[2019-11-08T08:05:15] Walked 2 items in 1.506326 seconds (1.327734 files/sec)
-rw-r--r-- 1 kilian ruthm 0 Nov  8 07:59 /scratch/users/kilian/test/filename with spaces

but it would be nice if dfind could work like find:

$ find  /scratch/users/kilian/test/ -type f -exec ls -al {} \;
-rw-r--r-- 1 kilian ruthm 0 Nov  8 07:59 /scratch/users/kilian/test/filename with spaces

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions