2020-10-02 05:18:08 +02:00
|
|
|
#!/usr/local/bin/v run
|
2021-04-20 16:16:35 +02:00
|
|
|
|
2020-10-02 05:18:08 +02:00
|
|
|
// The shebang above associates the file to V on Unix-like systems,
|
|
|
|
// so it can be run just by specifying the path to the file
|
|
|
|
// once it's made executable using `chmod +x`.
|
2019-12-07 16:27:09 +01:00
|
|
|
|
2021-04-20 16:16:35 +02:00
|
|
|
for _ in 0 .. 3 {
|
2020-10-02 05:18:08 +02:00
|
|
|
println('V script')
|
|
|
|
}
|
2019-12-07 16:27:09 +01:00
|
|
|
|
2020-10-02 05:18:08 +02:00
|
|
|
println('\nMaking dir "v_script_dir".')
|
2022-05-13 05:56:21 +02:00
|
|
|
mkdir('v_script_dir')?
|
2019-12-07 16:27:09 +01:00
|
|
|
|
2020-10-02 05:18:08 +02:00
|
|
|
println("\nEntering into v_script_dir and listing it's files.")
|
2022-05-13 05:56:21 +02:00
|
|
|
chdir('v_script_dir')?
|
2022-04-12 12:38:40 +02:00
|
|
|
files := ls('.') or { panic(err) }
|
2020-10-02 05:18:08 +02:00
|
|
|
println(files)
|
2019-12-07 16:27:09 +01:00
|
|
|
|
2020-10-02 05:18:08 +02:00
|
|
|
println('\nCreating foo.txt')
|
2022-05-13 05:56:21 +02:00
|
|
|
create('foo.txt')?
|
2019-12-07 16:27:09 +01:00
|
|
|
|
2020-10-02 05:18:08 +02:00
|
|
|
println('\nFiles:')
|
2022-04-12 12:38:40 +02:00
|
|
|
again_ls := ls('.') or { panic(err) }
|
2020-10-02 05:18:08 +02:00
|
|
|
println(again_ls)
|
2019-12-07 16:27:09 +01:00
|
|
|
|
2020-10-02 05:18:08 +02:00
|
|
|
println('\nRemoving foo.txt and v_script_dir')
|
2022-05-13 05:56:21 +02:00
|
|
|
rm('foo.txt')?
|
|
|
|
chdir('../')?
|
|
|
|
rmdir('v_script_dir')?
|
2019-12-07 16:27:09 +01:00
|
|
|
|
2020-10-02 05:18:08 +02:00
|
|
|
print('\nDoes v_script_dir still exist? ')
|
|
|
|
println(exists('v_script_dir'))
|