marcus-g
9/23/2017 - 2:55 AM

Get all bash arguments, except the last, and the last seperately

Useful for performing operations on all bash functional arguments except the final one, which gets treated differently. I used it for a bashrc function that commits all files listed in arguments except the last. The last argument becomes the git message

  local num_additions=$(($#-1))                                             
  local additions=${@:1:$num_additions}                                     
  local commit_message=${!#}                                                
  git add $additions && git commit -m $commit_message