1 | #!/usr/local/bin/v |
2 | |
3 | // The shebang above associates the file to V on Unix-like systems, |
4 | // so it can be run just by specifying the path to the file |
5 | // once it's made executable using `chmod +x`. |
6 | |
7 | // Note that you can also use: `#!/usr/bin/env -S v crun`, if your system supports the -S flag to env |
8 | // The benefit is that in this case, v could be anywhere in your path, while /usr/bin/env is guaranteed |
9 | // to be present on most Unix systems in that exact place. |
10 | |
11 | for _ in 0 .. 3 { |
12 | println('V script') |
13 | } |
14 | |
15 | println('\nMaking dir "v_script_dir".') |
16 | mkdir('v_script_dir')! |
17 | |
18 | println("\nEntering into v_script_dir and listing it's files.") |
19 | chdir('v_script_dir')! |
20 | files := ls('.') or { panic(err) } |
21 | println(files) |
22 | |
23 | println('\nCreating foo.txt') |
24 | create('foo.txt')! |
25 | |
26 | println('\nFiles:') |
27 | again_ls := ls('.') or { panic(err) } |
28 | println(again_ls) |
29 | |
30 | println('\nRemoving foo.txt and v_script_dir') |
31 | rm('foo.txt')! |
32 | chdir('../')! |
33 | rmdir('v_script_dir')! |
34 | |
35 | print('\nDoes v_script_dir still exist? ') |
36 | println(exists('v_script_dir')) |