elif echo file grep qs then fileecho file sed s fileHOMEfile Precede an initial

Elif echo file grep qs then fileecho file sed s

This preview shows page 1 - 2 out of 2 pages.

elif echo "$file" | grep -qs '^~' ; then file=$(echo "$file" | sed 's/.//') file=$HOME$file # Precede an initial dot (whether this dot denotes the working directory, # is the first dot of the two dots that denote the parent of the working directory, # or is the first dot of a file or a directory name that starts with a dot) # with the absolute pathname of the working directory ending in /.. elif echo "$file" | grep -qs '^\.' ; then file=$(pwd)/$file
Image of page 1

Subscribe to view the full document.

fi # _getfilename will be confused if it is called from a directory different # to the directory that contains the file it will read to possibly extract filenames. # We remember the current directory so that we can inform the user that the Makefile # is created in a directory different to the one from which the script is being executed, # if that is the case. original_dir=$(pwd) file_dir=$(dirname "$file") cd "$file_dir" getfilename_output=$(_getfilenames "$file") if [ $? -ne 0 ] ; then exit 1; fi # Extract the name of the directory where the file with the main() function resides. main_dir=$(echo "$getfilename_output" | sed 's/ .*//') main_dir=$(echo "$main_dir" | tr '#' ' ') # If a Makefile produced by _mmakefile already exists # then this Makefile is automatically removed. # Otherwise, the script prompts the user to whether the existing Makefile # can be removed, proceeds if user answers yes, and exits otherwise. if [ -e "${main_dir}Makefile" ] && ! grep -qs '^# Makefile produced by _mmakefile$' "${main_dir}Makefile" ; then echo A makefile already exists while true; do echo -n 'Do you want to replace the existing Makefile (yes/no)? ' read if [ $REPLY = yes -o $REPLY = y ] ; then break elif [ $REPLY = no -o $REPLY = n ] ; then exit 0 else echo -n 'Incorrect answer. ' fi done fi _mmakefile $getfilename_output if [ $? -ne 0 ] ; then exit 1; elif [ "$main_dir" != "$original_dir/" ] ; then echo Makefile created in "$main_dir" fi
Image of page 2
  • Fall '19
  • 11

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes