C:\var\tmpassuming that your current drive is the C: drive.
\\and output a single
foo baras a single argument.
joincommand (and associated functions) to build paths. If the '\' was used as the escape character then every call to join would have to be wrapped in a function to escape the resulting path.
^is that when constructing paths with tools like
joinyou don't need to do any escaping.
lscommand is then called with that list of files as command line arguments.
whichfunction will search for a matching application with each of the extensions in PATHEX.