#!/usr/bin/env bash # # This file is part of the LibreOffice project. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. #
# add-modelines, a simple script to add comments to # the beginning and end of source files for LibreOffice devs
# Blame goes to Jesse Adelman (at least at first) # someone AT boldandbusted dotty-dot com # http://www.boldandbusted.com/ # (c) 2010 Bold and Busted LLC
# NOTE: At present, this script only works for files with C-like comments. # NOTE: If you don't specify -p, the script will act on the current working directory. # NOTE: If no arguments are specified, the definitions below are in effect.
# TO DO # - Deuglify? # - Make source file type agnostic modelines? # - Too many/too few comments? # - Handle top level source directories with whitespace names? (Do they exist?)
# Turn off globbing, helps with SourceFiles
set -f
# Set defaults (don't change these)
ModelineReplace="false"
# Functions
function SetEnvironment()
{ if ! command -v tail || ! command -v head; then
echo "Missing head or tail, exiting..."
exit 1
fi if ! command -v find; then
echo "Missing find, exiting..."
exit 1
fi
}
function EditFile()
{
local FileToEdit
local currentFirstLine
local currentLastLine