File: _array.txt

package info (click to toggle)
yash 2.60-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,152 kB
  • sloc: ansic: 34,578; makefile: 851; sh: 808; sed: 16
file content (86 lines) | stat: -rw-r--r-- 2,327 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
= Array built-in
:encoding: UTF-8
:lang: en
//:title: Yash manual - Array built-in

The dfn:[array built-in] prints or modifies link:params.html#arrays[arrays].

[[syntax]]
== Syntax

- +array+
- +array {{name}} [{{value}}...]+
- +array -d {{name}} [{{index}}...]+
- +array -i {{name}} {{index}} [{{value}}...]+
- +array -s {{name}} {{index}} {{value}}+

[[description]]
== Description

When executed without any option or operands, the built-in prints all array
definitions to the standard output in a form that can be parsed as commands.

When executed with {{name}} and {{value}}s (but without an option), the
built-in sets the {{value}}s as the values of the array named {{name}}.

With the +-d+ (+--delete+) option, the built-in removes the {{index}}th values
of the array named {{name}}.
The number of values in the array will be decreased by the number of the
{{index}}es specified.
If the {{index}}th value does not exist, it is silently ignored.

With the +-i+ (+--insert+) option, the built-in inserts {{value}}s into the
array named {{name}}.
The number of values in the array will be increased by the number of the
{{value}}s specified.
The values are inserted between the {{index}}th and next values.
If {{index}} is zero, the values are inserted before the first value.
If {{index}} is larger than the number of values in the array, the values are
appended after the last element.

With the +-s+ (+--set+) option, the built-in sets {{value}} as the {{index}}th
value of the array named {{name}}.
The array must have at least {{index}} values.

[[options]]
== Options

+-d+::
+--delete+::
Delete array values.

+-i+::
+--insert+::
Insert array values.

+-s+::
+--set+::
Set an array value.

[[operands]]
== Operands

{{name}}::
The name of an array to operate on.

{{index}}::
The index to an array element. The first element has the index of 1.

{{value}}::
A string to which the array element is set.

[[exitstatus]]
== Exit status

The exit status of the array built-in is zero unless there is any error.

[[notes]]
== Notes

The array built-in is not defined in the POSIX standard.
Yash implements the built-in as an link:builtin.html#types[extension].

The command +array {{name}} {{value}}...+ is equivalent to the assignment
+{{name}}=({{value}}...)+.

// vim: set filetype=asciidoc textwidth=78 expandtab: