我有一个要在群集中运行的bash脚本。但是我遇到了以下错误:
history.push
我想做的是读取目录中的所有文件。然后根据该文件是否带有单词“ hard”,“ soft”或“ neutral”,我要在集群上运行特定命令。
import React, { useState /* , useEffect */ } from 'react'
import useForm from 'react-hook-form'
import Logo from '../assets/images/logo-icon-orange.png'
import TextInput from '../components/TextInput'
import Footer from '../components/Footer'
import AnimatedButton from '../components/AnimatedButton'
import logger from '../logger'
import { sleep } from '../utils/promise'
import PasswordResetSchema from './validation/PasswordResetSchema'
const PasswordResetPage = ({ history }) => {
const [isSubmitting, setSubmitting] = useState(false)
// const [isDone, setDone] = useState(false)
const { register, handleSubmit, errors } = useForm({
validationSchema: PasswordResetSchema,
})
const onSubmit = async data => {
setSubmitting(true)
await sleep(2000)
logger.info('form data', data)
// setDone(true)
history.push('/confirmation')
}
// useEffect(() => {
// if (isDone) {
// history.push('/confirmation')
// }
// })
return (
<form onSubmit={handleSubmit(onSubmit)} noValidate>
<div className="text-center mb-4">
<img className="mb-4" src={Logo} alt="Striver" width={72} />
<h1 className="h3 mb-3 font-weight-normal">Password reset</h1>
<p>Enter your email address below and we will send you instructions on how you can reset your password.</p>
</div>
<div className="form-label-group">
<TextInput type="email" id="email" register={register} label="Email address" errors={errors} />
</div>
<AnimatedButton actionTitle="Next" isSubmitting={isSubmitting} />
<Footer />
</form>
)
}
export default PasswordResetPage
完成
此代码应生成文件,但出现上述错误。有人可以解释为什么我收到此错误吗?
答案 0 :(得分:2)
在bash中,变量赋值在名称和值之间不允许有空格。 i_hard = 0
解释为命令i_hard
,用两个参数调用:=
和0
。请改用以下内容:
i_hard=0
答案 1 :(得分:1)
据我所知,赋值运算符周围不应有空格,如下所示:
variable=6