mongo-c-driver
mongo-c-driver copied to clipboard
CDRIVER-5509 Use Bash and shebangs whenever able
Summary
Addresses CDRIVER-5509. Verified by this patch.
For the most part, our scripts all use Bash already following prior on EVG config refactoring and script hygiene improvements such as in https://github.com/mongodb/mongo-c-driver/issues/1193 and https://github.com/mongodb/mongo-c-driver/pull/1187.
This PR continues the prior work to ensure consistent use of shebangs and script invocation in our EVG, build, and utility scripts.
Shebangs
This PR applies #!/usr/bin/env bash
to all our shebangs for consistency with the pattern being used by DET scripts: https://github.com/mongodb-labs/drivers-evergreen-tools/pull/458
Scripts related to Debian packaging are left unmodified due to the special environment requirements. These may also be updated for consistency if it turns out not to be an issue.
Script Invocation
This PR adds the executable permission bit to all shell scripts and invokes them directly (e.g. ./script.sh
instead of bash script.sh
) to respect shebangs. Otherwise our invocation risks overriding the preferred shell for which the script is intended to be used.
License Notice in Uninstall Script
https://github.com/mongodb/mongo-c-driver/pull/1655 overlooked some minor formatting issues with the license notice embedded in the generated uninstall script.
#!/bin/sh
# * Mongo C Driver uninstall program, generated with CMake
# *
# * Copyright 2009-present MongoDB, Inc.
# *
# * 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.
# *
set -eu
...
This PR tidies it up a bit to look as follows:
#!/usr/bin/env bash
#
# Mongo C Driver uninstall program, generated with CMake
#
# Copyright 2009-present MongoDB, Inc.
#
# 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.
set -eu
...
Similarly for the Windows CMD script, before:
@echo off
rem Mongo C Driver uninstall program, generated with CMake
rem
rem Copyright 2009-present MongoDB, Inc.
rem
rem Licensed under the Apache License, Version 2.0 (the \"License\")
rem
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an \"AS IS\" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem
call :init
...
and after:
@echo off
rem Mongo C Driver uninstall program, generated with CMake
rem
rem Copyright 2009-present MongoDB, Inc.
rem
rem Licensed under the Apache License, Version 2.0 (the "License")
rem
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
call :init
...