<commit_before>#!/bin/bash -
# This is still a work in progress. I want to make this handle both custom host
# files.
# TODO:
# * Consider a lock to prevent races between add_host and rm_host. $ACTIVE_FLAG 
#   might make a good lock.
# * $HOME env variable and consequently the $HOST_DIR env variable. Potentially
#   {add,rm}_host may act on different files to {start,stop}_block. Note that
#   this won't present itself if you only use sudo. Reconsider what you want
#   $HOST_DIR to be. On a a single user machine /var/ may be a good choice.

set -u # Prevent unset variables
set -e # Stop on an error


# Put the original in the dotfiles repo, so it shows up with git status
HOST_DIR="$HOME/.hosts"

# Create HOST_DIR if doesn't exist
mkdir -p $HOST_DIR

# Actual host file to be swapped around.
HOST_FILE="/etc/hosts"
<commit_msg>Set the pipefail flag in the hosts_manager script.<commit_after>#!/bin/bash -
###############################################################################
# This is still a work in progress. I want to make this handle both custom host
# files.
# TODO:
# * Consider a lock to prevent races between add_host and rm_host. $ACTIVE_FLAG 
#   might make a good lock.
# * $HOME env variable and consequently the $HOST_DIR env variable. Potentially
#   {add,rm}_host may act on different files to {start,stop}_block. Note that
#   this won't present itself if you only use sudo. Reconsider what you want
#   $HOST_DIR to be. On a a single user machine /var/ may be a good choice.
###############################################################################

set -u # Prevent unset variables
set -e # Stop on an error
set -o pipefail # Pipe exit code should be non-zero when a command in it fails

###############################################################################
# Variables
###############################################################################

# Put the original in the dotfiles repo, so it shows up with git status
HOST_DIR="$HOME/.hosts"

# Create HOST_DIR if doesn't exist
mkdir -p $HOST_DIR

# Actual host file to be swapped around.
HOST_FILE="/etc/hosts"

{'fraction_non_alphanumeric': 0.21273584905660378, 'fraction_numerical': 0.0, 'mean_word_length': 4.4524421593830334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2338155', 'n_tokens_mistral': 591, 'n_tokens_neox': 562, 'n_words': 273}