Skip to content

Instantly share code, notes, and snippets.

@jonboulle
Created April 13, 2016 14:19
Show Gist options
  • Save jonboulle/469513c5311fa3c7979494473353efdd to your computer and use it in GitHub Desktop.
Save jonboulle/469513c5311fa3c7979494473353efdd to your computer and use it in GitHub Desktop.
license header creator thingy
#!/bin/bash
tmp=$(mktemp) # Create a temporary file
trap "rm -f $tmp; exit 1" 0 1 2 3 13 15
header='// Copyright 2016 The Foo Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
'
for file in $@; do
{
echo "$header"
cat $file
} > $tmp
mv $tmp $file
done
rm -f $tmp
trap 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment