\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[a4paper, margin=0.75in]{geometry}

% set up hyperlink coloring
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,
    urlcolor=cyan
}

\setlength{\parindent}{0pt} % no indentation

% checkbox list: https://tex.stackexchange.com/questions/247681/how-to-create-checkbox-todo-list
\usepackage{enumitem,amssymb}
\newlist{boxlist}{itemize}{2}
\setlist[boxlist]{label=$\square$}

% code support: listings and fancy verbatim
\usepackage{listings}
\lstset{basicstyle=\ttfamily\footnotesize}
\usepackage{fancyvrb}

\renewcommand{\familydefault}{\sfdefault} % default to sans serif

\usepackage{xcolor}
\newcommand{\code}[1]{\colorbox{lightgray}{\texttt{#1}}}
\newcommand{\sh}[1]{\code{\$ #1}}

%%%%%%%%%%%%%%%%
\begin{document}

\title{Advanced 4\\Bash and Regex}
\author{EECS 201 Fall 2020}
\date{}
\maketitle

\section*{Submission Instructions}
This assignment will be submitted as a repository on the \href{https://gitlab.umich.edu}{UMich GitLab server}.
Create a Project on it with the name/path \code{eecs201-adv4} and add \code{brng} as a Reporter.
The repository should have the following directory structure, starting from the repository's root:
\begin{lstlisting}
/
|-- report.txt
|-- pig-latinfy.sh
\end{lstlisting}

\section*{Preface}
I highly suggest that you do this homework in a Linux environment,
be it WSL on Windows (on the Linux filesystem, not the Windows filesystem)
or your Ubuntu virtual machine.
The reasoning for this is that some tools that deal with regular expressions
(namely for this assignment: \code{sed}) may differ in behavior depending on *nix system.
Linux systems use GNU \code{sed} and \code{grep} while macOS (and FreeBSD)
use BSD \code{sed} and \code{grep} which have some subtle differences in behavior.
In particular, GNU \code{sed} on Linux has some helpful extensions that can deal with a particular case.
\\\\
In this assignment you'll be provided yet another zipped archive containing some starter empty files and scripts.
\begin{lstlisting}[language=bash]
$ wget https://www.eecs.umich.edu/courses/eecs201/files/assignments/adv4.tar.gz
\end{lstlisting}

Initialize a Git repository in the extracted \code{adv4} directory,
adding all of the script files and committing them.
Create a \textbf{private} project with the name/URL \code{eecs201-adv4} on the UMich GitLab (\url{gitlab.umich.edu})
and add the instructor \code{brng} as a \textbf{Reporter}.
Set this UMich GitLab project as your remote: you'll be pushing to it in order to submit.

\section{More \texttt{sed} fun (10)}
Pig Latin is language game in which English words are made to sound like a faux-Latin
by moving around groupings of letters.

Here are the basic rules for this exercise's variant:
\begin{enumerate}
  \item For words that begin with a single consonant before running into a vowel, the consonant is moved to the end and ``ay'' is added after.
    \begin{itemize}
      \item ``\underline{h}ello'' = ``ello\underline{h}ay''
      \item ``\underline{c}at'' = ``at\underline{c}ay''
      \item ``\underline{l}iquid'' = ``iquid\underline{l}ay''
    \end{itemize}
  \item For words that begin with a multiple consonants before running into a vowel, the consonant group is moved to the end and ``ay'' is added after.
    \begin{itemize}
      \item ``\underline{str}ing'' = ``ing\underline{str}ay''
      \item ``\underline{fr}iend'' = ``iend\underline{fr}ay''
      \item ``\underline{wr}ong'' = ``ong\underline{wr}ay''
    \end{itemize}
  \item For words that begin with a vowel, ``yay'' is simply added at the end.
    \begin{itemize}
      \item ``I'' = ``I\underline{yay}''
      \item ``apply'' = ``apply\underline{yay}''
      \item ``income'' = ``income\underline{yay}''
    \end{itemize}
  \item For this Pig Latin variant, the letter 'y' is always a consonant.
\end{enumerate}

For this exercise, write an \textbf{executable Bash} script called \code{pig-latinfy.sh} that takes its input on standard input and turns it into Pig Latin and outputs the translation. \textbf{Be sure to set the shebang appropriately!}
If you are on WSL and doing this on the Windows filesystem, be sure to have Git set the execute bits (look up how to do this)!
The big caveats are:
\begin{itemize}
  \item Each word on a line will be translated.
  \item Words with a punctuation mark adjacent will be translated and retain the punctuation mark.
        For example: ``goodbye!'' = ``oodbyegay!''
  \item Capitalization of the word is preserved. For example: ``My name is John" = ``My amenay isyay Ohnjay".
  \item Hyphenated words consider each component to be a separate word. For example: ``part-time'' = ``artpay-imetay''.
  \item Spacing will be preserved. For example: ``hello~~~~world'' = ``ellohay~~~~orldway''
\end{itemize}
The \texttt{adv4} directory has example text and their translated versions for reference.

\subsubsection*{Helpful hints}
\begin{itemize}
  \item There are other anchors beside `\texttt{\^{}}' and `\texttt{\${}}': the
        \href{https://www.gnu.org/software/grep/manual/grep.html#The-Backslash-Character-and-Special-Expressions}
        {GNU \texttt{grep} manual} documents some.
  \item GNU \texttt{sed} has extensions that deal with upper/lower case conversion.
        \href{https://www.gnu.org/software/sed/manual/sed.html#The-_0022s_0022-Command}
             {Its manual's section on the \texttt{s} command is enlightening}.
\end{itemize}


\section{Conclusion}
\begin{enumerate}
  \item Add and commit any changes you intend to submit.
  \item Create a file called \code{report.txt}.
  \item On the first line provide an integer time in minutes of how long it took
        for you to complete this assignment.
  \item On the second line and beyond, write down what you learned while doing this assignment.
        If you already knew how to do all of this, put down ``N/A''.
  \item Add and commit this \code{report.txt} file.
\end{enumerate}


\end{document}
