Bcopy » History » Version 7
Per Amundsen, 02/14/2023 05:10 PM
| 1 | 5 | Per Amundsen | _Added in 1.9.0_ |
|---|---|---|---|
| 2 | |||
| 3 | 4 | Per Amundsen | */bcopy [-zc] <&binvar> <N> <&binvar> <S> <M>* |
| 4 | 1 | Per Amundsen | |
| 5 | Copies <M> bytes from position <S> in the second &binvar to the first &binvar at position <N>. |
||
| 6 | This can also be used to copy overlapping parts of a &binvar to itself. |
||
| 7 | |||
| 8 | *Switches* |
||
| 9 | |||
| 10 | 7 | Per Amundsen | table(ktable). |
| 11 | |*Switch*|*Description*| |
||
| 12 | | -z | The bytes in the second &binvar that is copied are zero-filled after the copy. | |
||
| 13 | | -c | The first &binvar is chopped to <N> + <M>. | |
||
| 14 | 1 | Per Amundsen | |
| 15 | *Parameters* |
||
| 16 | |||
| 17 | 7 | Per Amundsen | table(ktable). |
| 18 | |*Parameter*|*Description*| |
||
| 19 | | <&binvar> | Target &binvar to copy to. | |
||
| 20 | | <N> | Target position in the first &binvar to copy to. (If N = -1, bytes are appended to the destination &binvar) | |
||
| 21 | | <&binvar> | Source &binvar to copy from. | |
||
| 22 | | <S> | Source position to copy from. | |
||
| 23 | | <M> | Number of bytes to copy. | |
||
| 24 | 1 | Per Amundsen | |
| 25 | *Example* |
||
| 26 | |||
| 27 | 2 | Per Amundsen | <pre> |
| 28 | 1 | Per Amundsen | alias /example { |
| 29 | ;Create a binary variable and assign it some text |
||
| 30 | bset -t &example 1 This is a test! |
||
| 31 | |||
| 32 | ;Copy from 'example' from the 11th byte 10 bytes onward |
||
| 33 | ;Zero-fill the part that was copied |
||
| 34 | bcopy -z &example2 1 &example 11 10 |
||
| 35 | |||
| 36 | ;Print out &example's content (up to the first null) |
||
| 37 | echo -a $bvar(&example, 1-).text |
||
| 38 | |||
| 39 | ;Print out &example2's content |
||
| 40 | echo -a $bvar(&example2, 1-).text |
||
| 41 | } |
||
| 42 | 2 | Per Amundsen | </pre> |