Results for “variable”
Small, practical examples. Search by task or narrow things down below.
Clear an owning pointer after releasing its allocation
C: Assigning NULL helps prevent accidental reuse through the same variable.
C✓ Tested
Convert a string to lowercase
Normalize a text value using Bash expansion.
lowercase✓ Tested
Export a value to child processes
Bash Scripts: Only exported shell variables are inherited through the environment.
Bash Scripts✓ Tested
Format a zero-padded numeric label
Linux Commands: Use printf formatting instead of concatenating a variable number of zeroes.
Linux Commands✓ Tested
Give a function an optional argument
Let callers omit a value while keeping nounset enabled.
optional argument✓ Tested
Insert values into a multiline template
PowerShell: A double-quoted here-string expands variable references.
PowerShell✓ Tested
Keep exec-form arguments literal
Docker / Compose: JSON exec form does not expand shell environment variables.
Docker / Compose✓ Tested
Keep function state between calls
C: A static local variable retains its stored value for the lifetime of the process.
C✓ Tested
Keep function-local assignments separate from caller state
PowerShell: Ordinary function assignments create local variables rather than replacing the caller’s variable.
PowerShell✓ Tested
Narrow an object using a type pattern
C#: A successful is pattern introduces a strongly typed local variable.
C#✓ Tested
Provide a default environment value
Set a runtime default that can be overridden at startup.
Dockerfile✓ Tested
Remove a filename extension
Keep the path while removing its final extension.
filename✓ Tested