Avoid a process spawn in trim function using bash internals.