1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env rust-script
//! Define external dependencies as we do in a Cargo.toml file.
//! ```cargo
//! [dependencies]
//! sh-exec = "*"
//! ```
//!
/*
## Example: convert a bash script to Rust using sh-exec
## This example demonstrates how to convert a simple bash script into Rust using the `sh-exec` library.
## The original bash script prints a greeting, asks for the user's name, and shows the current date.
## The Rust version uses the `sh-exec` library to execute shell commands and handle errors.
## Original Bash Script:
#!/bin/bash
# Print a greeting
echo "Hello, World!"
# Ask for the user's name
read -p "What is your name? " name
# Print a personalized message
echo "Hello, $name!"
# Show the current date
echo "Today's date is: $(date)"
*/
use *;