Results for “script”
Small, practical examples. Search by task or narrow things down below.
Read the first collection element
TypeScript: Access index zero only after establishing that the collection is nonempty.
TypeScript✓ Tested
Read the length of an ASCII string
Bash Scripts: Read the length of an ASCII string with a small standalone Bash program.
Bash Scripts✓ Tested
Recover from an expected promise rejection
JavaScript: Return a fallback from catch so later handlers receive an ordinary resolved value.
JavaScript✓ Tested
Recover from an expected promise rejection
TypeScript: Return a fallback from catch so later handlers receive an ordinary resolved value.
TypeScript✓ Tested
Redirect an entire group of commands
Bash Scripts: Brace grouping runs in the current shell and shares a single output redirection.
Bash Scripts✓ Tested
Refuse to overwrite an existing file with redirection
Bash Scripts: Noclobber makes a plain greater-than redirection fail when the target already exists.
Bash Scripts✓ Tested
Reject a missing required configuration value
Bash Scripts: Check a required value explicitly and emit a controlled diagnostic before exiting.
Bash Scripts✓ Tested
Remove a known prefix with a shell pattern
Bash Scripts: The hash expansion removes the shortest matching prefix without changing the original variable.
Bash Scripts✓ Tested
Remove a Map entry and detect whether it existed
JavaScript: Map.delete returns true only when an entry was present.
JavaScript✓ Tested
Remove a Map entry and detect whether it existed
TypeScript: Map.delete returns true only when an entry was present.
TypeScript✓ Tested
Remove a trailing carriage return from a line
Bash Scripts: Use an ANSI-C quoted carriage return as the suffix pattern.
Bash Scripts✓ Tested
Remove a variable from one child’s environment
Bash Scripts: env -u removes an inherited value for a single command.
Bash Scripts✓ Tested