-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_escapes.dush
More file actions
30 lines (24 loc) · 975 Bytes
/
Copy pathstring_escapes.dush
File metadata and controls
30 lines (24 loc) · 975 Bytes
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
// String escape sequences — double-quoted strings only.
// Single-quoted strings stay raw.
// --- Basic escapes ---
echo "tab:\there"
echo "newline:\nsecond line"
echo "cr:\rafter-cr"
echo "quote: \" backslash: \\ apostrophe: \'"
echo "nul byte:<\0>"
// --- Hex and unicode ---
echo "\x41\x42\x43" // "ABC"
echo "\u{1F600}" // 😀
echo "\u{41} \u{42}" // "A B"
// --- Suppressing @ interpolation with \@ ---
@name = "world"
echo "hello @name" // interpolates → "hello world"
echo "hello \@name" // literal → "hello @name"
// --- Raw strings keep backslashes ---
echo 'tab:\there' // literal backslash-t-h-e-r-e
echo 'no @interp here' // literal @interp
// --- Unknown escapes are kept as-is (forgiving) ---
echo "\q literal" // prints "\q literal"
// --- Escapes inside interpolated expressions ---
@line = "line1\nline2"
echo @line // two lines