-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create task2 #275
base: master
Are you sure you want to change the base?
Create task2 #275
Conversation
Modifying the task 1 and include more commands with error handling if statement
Hi Ajay, Please complete all the day11 Tasks and then create a pull request. Also, you need to add a photo of the code with its output. I have a suggestion: make sure the subject line is clear and specific. For example, you wrote Create task2, but it's not clear which task and from which day. Right? I checked your profile, and I see you're new to GitHub. That's okay! You can refer to this video for help: Git and GitHub Master Class By Shubham Londhe. |
Stale pull request message |
WalkthroughThis pull request introduces a new Bash script that enhances file and directory management through the implementation of three key functions: Changes
Poem
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional comments not posted (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- 2024/day11/task2 (1 hunks)
Additional comments not posted (1)
2024/day11/task2 (1)
6-12
: LGTM!The code changes are approved.
function create_file { | ||
read -p "create a file : " filename | ||
file=$filename | ||
touch_file=($(touch "$source_dir/$file")) | ||
echo "print file name $file" | ||
err_handle | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused variable.
The touch_file
variable is unused and can be removed.
Apply this diff to remove the unused variable:
- touch_file=($(touch "$source_dir/$file"))
+ touch "$source_dir/$file"
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
function create_file { | |
read -p "create a file : " filename | |
file=$filename | |
touch_file=($(touch "$source_dir/$file")) | |
echo "print file name $file" | |
err_handle | |
} | |
function create_file { | |
read -p "create a file : " filename | |
file=$filename | |
touch "$source_dir/$file" | |
echo "print file name $file" | |
err_handle | |
} |
function create_dir { | ||
read -p "create a directory : " directory | ||
source_dir=$directory | ||
mk_dir=($(mkdir $source_dir)) | ||
echo "print directory name $source_dir" | ||
err_handle | ||
create_file | ||
err_handle | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused variable and check if the directory already exists.
The function has the following issues:
- The
mk_dir
variable is unused and can be removed. - The function should check if the directory already exists before creating it.
Apply this diff to remove the unused variable and check if the directory already exists:
- mk_dir=($(mkdir $source_dir))
+ if [ -d "$source_dir" ]; then
+ echo "Directory $source_dir already exists."
+ else
+ mkdir "$source_dir"
+ fi
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
function create_dir { | |
read -p "create a directory : " directory | |
source_dir=$directory | |
mk_dir=($(mkdir $source_dir)) | |
echo "print directory name $source_dir" | |
err_handle | |
create_file | |
err_handle | |
} | |
function create_dir { | |
read -p "create a directory : " directory | |
source_dir=$directory | |
if [ -d "$source_dir" ]; then | |
echo "Directory $source_dir already exists." | |
else | |
mkdir "$source_dir" | |
fi | |
echo "print directory name $source_dir" | |
err_handle | |
create_file | |
err_handle | |
} |
Stale pull request message |
Modifying the task 1 and include more commands with error handling if statement
Summary by CodeRabbit