Let’s say I have C:\Users\User\Pictures\mypic.png
as an argument, it should return 1. Now, if I have [0] or 4, then it returns 0.
Something like ${is_image_arg\ $1}
, but with space in mind.
Let’s say I have C:\Users\User\Pictures\mypic.png
as an argument, it should return 1. Now, if I have [0] or 4, then it returns 0.
Something like ${is_image_arg\ $1}
, but with space in mind.
I’d say:
isfile(['{/$arg}'])
although this explicitely makes the OS to check if the filename exists (and if filenames with malicious names as [0]
exists, then… potential troubles…).
But you see that the question is actually very difficult to answer : “Giving any kind of input string, tell me if that is a filename or not ?”
As filenames can be almost any kind of string…
So, then this question becomes on checking if it contains a file extension and is a valid file. I know isin() would help verify if it contains a file extension. I could use 0 => $1
in a separate command and extract extension.
Ok, I think this will work out, what can go wrong?
foo_test_command:
is_file:=isfile(['"$*"'])
0 => "$*"
ext={-1,x}
is_valid_ext:=isin('$ext','png','txt','gpl','pal','pdn')
rm. u {$is_file&&$is_valid_ext}
This means I will have to create a new command to specifically open .pal file, but eh. Not too hard.