POSIX Shell Programming Challenge - Programming On Unix

Users browsing this thread: 1 Guest(s)
seninha
Long time nixers
(12-04-2021, 11:47 AM)s0kx Wrote: Came up with something really horrible looking before remembering that wsl of course uses bash, which makes me disqualifed. Like mort's example, this also breaks with empty directories. I will certainly be returning to this challenge later..

Code:
~ $ for i in test/{*,.*[^..]}; do echo $i; done
test/directorywithfiles
test/file with spaces.txt
test/textfile.txt
test/.hiddenfile.txt
~ $

It also fails when there is no hidden file.
Quoting from The UNIX Programming Environment:

Quote:What happens if no files match the pattern? The shell, rather than complaining (as it did in early versions), passes the string on as though it had been quoted. …

Code:
$ ls x*y
x*y not found
$ >xyzzy
$ ls x*y
xyzzy
$ ls 'x*y'
x*y not found


Messages In This Thread
POSIX Shell Programming Challenge - by mort - 12-04-2021, 10:36 AM
RE: POSIX Shell Programming Challenge - by movq - 12-04-2021, 10:49 AM
RE: POSIX Shell Programming Challenge - by s0kx - 12-04-2021, 11:47 AM
RE: POSIX Shell Programming Challenge - by s0kx - 12-04-2021, 01:31 PM
RE: POSIX Shell Programming Challenge - by jkl - 12-04-2021, 01:34 PM
RE: POSIX Shell Programming Challenge - by sth - 12-04-2021, 01:36 PM
RE: POSIX Shell Programming Challenge - by mort - 12-04-2021, 01:52 PM
RE: POSIX Shell Programming Challenge - by mort - 12-04-2021, 02:35 PM
RE: POSIX Shell Programming Challenge - by seninha - 12-04-2021, 02:35 PM
RE: POSIX Shell Programming Challenge - by movq - 13-04-2021, 03:34 PM
RE: POSIX Shell Programming Challenge - by s0kx - 16-04-2021, 02:50 AM
RE: POSIX Shell Programming Challenge - by s0kx - 01-05-2021, 04:56 AM