summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrozolotl <44589151+frozolotl@users.noreply.github.com>2024-03-23 12:54:50 +0100
committerLaurenz <laurmaedje@gmail.com>2024-05-17 14:27:58 +0200
commit784488c5225534ee7e3848df186d059cb6cbeed5 (patch)
treed874225b4ab958efa125007898f6ed0f66dd7c3c
parent3a5a4d9227f25ac9863b0af8e242b39bef71ae9c (diff)
Escape path and entrypoint in `typst init` output (#3753)
-rw-r--r--Cargo.lock7
-rw-r--r--Cargo.toml1
-rw-r--r--crates/typst-cli/Cargo.toml1
-rw-r--r--crates/typst-cli/src/init.rs12
4 files changed, 19 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index e054eace..9c94d559 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2132,6 +2132,12 @@ dependencies = [
]
[[package]]
+name = "shell-escape"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f"
+
+[[package]]
name = "simd-adler32"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2605,6 +2611,7 @@ dependencies = [
"serde",
"serde_json",
"serde_yaml 0.9.32",
+ "shell-escape",
"tar",
"tempfile",
"toml",
diff --git a/Cargo.toml b/Cargo.toml
index 689cb8f9..439d3edf 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -93,6 +93,7 @@ semver = "1"
serde = { version = "1.0.184", features = ["derive"] }
serde_json = "1"
serde_yaml = "0.9"
+shell-escape = "0.1.5"
siphasher = "1"
smallvec = { version = "1.11.1", features = ["union", "const_generics", "const_new"] }
stacker = "0.1.15"
diff --git a/crates/typst-cli/Cargo.toml b/crates/typst-cli/Cargo.toml
index 57251a64..65803a1d 100644
--- a/crates/typst-cli/Cargo.toml
+++ b/crates/typst-cli/Cargo.toml
@@ -51,6 +51,7 @@ semver = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
+shell-escape = { workspace = true }
tar = { workspace = true }
tempfile = { workspace = true }
toml = { workspace = true }
diff --git a/crates/typst-cli/src/init.rs b/crates/typst-cli/src/init.rs
index 01fdb02f..b0446bd1 100644
--- a/crates/typst-cli/src/init.rs
+++ b/crates/typst-cli/src/init.rs
@@ -104,11 +104,19 @@ fn print_summary(
out.set_color(&gray)?;
write!(out, "> ")?;
out.reset()?;
- writeln!(out, "cd {}", project_dir.display())?;
+ writeln!(
+ out,
+ "cd {}",
+ shell_escape::escape(project_dir.display().to_string().into()),
+ )?;
out.set_color(&gray)?;
write!(out, "> ")?;
out.reset()?;
- writeln!(out, "typst watch {}", template.entrypoint)?;
+ writeln!(
+ out,
+ "typst watch {}",
+ shell_escape::escape(template.entrypoint.to_string().into()),
+ )?;
writeln!(out)?;
Ok(())
}